wishlist
wishlist copied to clipboard
Linter/Fixer
What? Basically https://github.com/dense-analysis/ale, but only linter and fixer. Other things are already implemented via lsp.
Why? Linting is a thing that runs almost constantly, especially when real time execution is enabled. I believe having it in lua would improve the performance.
Potential existing implementations:
- https://github.com/dense-analysis/ale
- https://github.com/neomake/neomake
- https://github.com/vim-syntastic/syntastic
Potential pitfalls: Migrating all linter/fixer implementations that exist in ale, from vimscript to lua. Guess it can be done slowly over time.
I'm not a lua developer, but I can definitely help on this.
Just to clarify, this differs from the LSP-provided diagnostics in that it focuses on running standalone linters?
@wbthomason yeah, standalone linters and fixers. For example, most JS projects use eslint for linting, and prettier for fixing.
@kristijanhusak I just started using https://github.com/neovim/nvim-lspconfig#diagnosticls right now dealing with some issues configuring but looks like it is a replacement of ale. But I still need some time to confirm that is an alternative.
@carlitux I wasn't aware of that. I'll give it a try, thanks!
@kristijanhusak were you able to setup? I had many issues diagnosticls
@carlitux i haven't tried yet. Will get back to you when i try it.
How you describe "fixers" sounds actually more like a code formatter. At least that's what your example Prettier is doing. It does not fix your code. It just makes it standardized formatted. But it would deny to format if there are syntax errors for example. A tool that support this would be neoformat
Also https://github.com/mhartington/formatter.nvim
@wbthomason plans to support linters?
@carlitux Sorry, support linters in what? formatter.nvim
is not my project; this repo is just a place to collect ideas for people to adopt and implement.
@wbthomason sorry, I didn't read well. Thanks!
@carlitux I managed to set up linting with eslint, and prettier, with this config:
nvim_lsp.diagnosticls.setup{
filetypes={'javascript'},
init_options = {
linters = {
eslint = {
command = './node_modules/.bin/eslint',
rootPatterns = {'.git'},
debounce = 100,
args = {
'--stdin',
'--stdin-filename',
'%filepath',
'--format',
'json'
},
sourceName = 'eslint',
parseJson = {
errorsRoot = '[0].messages',
line = 'line',
column = 'column',
endLine = 'endLine',
endColumn = 'endColumn',
message = '${message} [${ruleId}]',
security = 'severity'
},
securities = {
[2] = 'error',
[1] = 'warning',
},
},
},
filetypes = {
javascript = 'eslint'
},
formatters = {
prettier = {
command = "./node_modules/.bin/prettier",
args = {"--stdin-filepath" ,"%filepath", '--single-quote', '--print-width 120'}
}
},
formatFiletypes = {
javascript = "prettier"
},
}
}
I wasn't able to set up eslint fix or prettier-eslint, it failed to spawn those, even though I have them installed. Linting looked fine.
It doesn't work for me because I thought it supports textDocument/range_formatting
, which is the only thing I'm currently missing from Ale.
@kristijanhusak issues with 'textDocument/definition' or 'textDocument/documentSymbol'? for me breaks others
@carlitux I didn't try to run any other LSP server besides it. Most likely there would be some issues in that case. I don't think it can work if you have more than 1 LSP per filetype.
Great stuff .. the config you posted worked perfectly @kristijanhusak
It would be nice to see the bugs worked out with multiple LSPs & single files. I was running a JS lang server & diagnosticls
; unfortunately, ran into similar issues as @carlitux .
Here's one of multiple LSP bugs that's currently being addressed: https://github.com/neovim/neovim/pull/12764
@carlitux I managed to set up linting with eslint, and prettier, with this config:
nvim_lsp.diagnosticls.setup{ filetypes={'javascript'}, init_options = { linters = { eslint = { command = './node_modules/.bin/eslint', rootPatterns = {'.git'}, debounce = 100, args = { '--stdin', '--stdin-filename', '%filepath', '--format', 'json' }, sourceName = 'eslint', parseJson = { errorsRoot = '[0].messages', line = 'line', column = 'column', endLine = 'endLine', endColumn = 'endColumn', message = '${message} [${ruleId}]', security = 'severity' }, securities = { [2] = 'error', [1] = 'warning', }, }, }, filetypes = { javascript = 'eslint' }, formatters = { prettier = { command = "./node_modules/.bin/prettier", args = {"--stdin-filepath" ,"%filepath", '--single-quote', '--print-width 120'} } }, formatFiletypes = { javascript = "prettier" }, } }
I wasn't able to set up eslint fix or prettier-eslint, it failed to spawn those, even though I have them installed. Linting looked fine. It doesn't work for me because I thought it supports
textDocument/range_formatting
, which is the only thing I'm currently missing from Ale.
Awesome! I was trying to do this today and this worked really well. Maybe we need some docs for right configuration?
Great stuff .. the config you posted worked perfectly @kristijanhusak
It would be nice to see the bugs worked out with multiple LSPs & single files. I was running a JS lang server & diagnosticls; unfortunately, ran into similar issues as @carlitux .
Here's one of multiple LSP bugs that's currently being addressed: neovim/neovim#12764
looks like this is fixed and working really well, just trying to find the best way to format before save right now with this config
if client.resolved_capabilities.document_formatting then
vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync{}")
end
Newer programming languages provide one tool for the linting. Older programming languages have many.
Is the goal to simplify or give any sort of reference on this?
@matu3ba literally a tool same as Ale mentioned in the first comment, but only the linter and fixer part. Ale has some other things that are not necessary since they are already implemented (LSP for example).
Does the linter/fixer need to be in lua when there is already an option to use the efm-languageserver (written in go) with lspconfig? The suggestion to use efm-language server for linting and formatting in neovim was made here efm-languageserver. I have been using this solution for a variety of languages and it works very well my implementation can be referenced here dots.
nvim-lint is promising: https://github.com/mfussenegger/nvim-lint/
I would suggest to keep linter and fixer separate programs as the fixer rewrites the file with the possibilities to mess up your files. (So I prefer to invoke simple binaries that may optionally read a project-local config and always work/never fail as to limit any possibilities of errors.)
The linter should only do static code analysis (on source- or intermediate representation) of the code.
@matu3ba agreed, right now I'm looking at nvim-lint and formatter.nvim as two strong candidates, but I still use efm personally.
Can anyone help me setting up nvim-lint for pylint(python)
Can anyone help me setting up nvim-lint for pylint(python)
I would suggest that you ask on the nvim-lint repo - this repo is for gathering wishes and candidates for their fulfillment.
You can try using null-ls. This plugin allows pretty much anything to be hooked up to the existing lsp protocol.
It includes plenty of builtins for different linters an formatters
I guess this is already done right? via what @sarmong mentioned, https://github.com/jose-elias-alvarez/null-ls.nvim
I would recommend nvim-lint, between the two of these what else are people missing?
I'm currently using https://github.com/creativenull/diagnosticls-configs-nvim, which provides predefined configs for diagnosticls.
@mjlbach Would you mind elaborating a bit on why you recommend using nvim-lint over null-ls, please? Genuinely curious.