-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linter/Fixer #9
Comments
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. |
@wbthomason plans to support linters? |
@carlitux Sorry, support linters in what? |
@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. |
@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. |
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 & Here's one of multiple LSP bugs that's currently being addressed: neovim/neovim#12764 |
Awesome! I was trying to do this today and this worked really well. Maybe we need some docs for right configuration? |
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. 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) |
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. |
IMO People just want OOTB configurations for linters/formatters,which is what
|
Thanks you very much for taking time to describe it in such detail. Really appreciated. |
I see that the difference between null-ls and nvim-lint is that the first one is for linter and fixer and the second only for linters. so there is a plugin just for fixers/formatters? something where you define a filetype and what to execute should be enough. |
I really want a Neovim Lua ecosystem equivalent to ALE's amazing auto-configuration (not auto-installation) of linters, fixers, and language servers. It's amazingly nice to be able to recommend to a new person that they should use a combo like packer.nvim + plenary.nvim + vim-polyglot + nvim-treesitter ( Both null-ls.nvim and nvim-lint follow the current pattern and don't provide auto-configuration for linters. |
I'm not sure I understand. Do you want users to have to opt-out of linters? require('lint').linters_by_ft = { markdown = {'vale',} }
vim.cmd [[ au BufWritePost * lua require('lint').try_lint() ]] Does not seem like much configuration at all. |
@mjlbach That is how ALE generally works, yes. (ALE will disable tools by default if they're found to be poor fits for auto-detection.) " Only run linters named in ale_linters settings.
let g:ale_linters_explicit = 1 I'd be fine with having auto-detection be opt-in; the complete lack of it is what I'm missing. I should note that Auto-detection is really nice when tools are only installed project-locally (e.g. via It's also just annoying when I know these plugins know which tools work for which languages and can easily & quickly figure out what I have installed. It's boilerplate that I shouldn't have to write. Also, when you use a lot of languages, the boilerplate adds up. I think being able to enable or disable auto-detection globally or buffer-locally and by language/filetype and tool would work (Again, you can mostly refer to what ALE currently has in terms of options.) I do think tool auto-detection could be split out into a separate plugin that can be shared between other plugins that need to deal with detecting the tools and their appropriate configuration & directories; the ALE situation of everything being in one plugin doesn't need to be emulated. |
Agreed, someone could create a |
Funnily enough, the maintainer of And somebody is collating quick configs for it: https://github.com/creativenull/efmls-configs-nvim |
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:
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.
The text was updated successfully, but these errors were encountered: