Comments (11)
thank @lithammer @walialu , I figured it out after reading the README in diagnostic-languageserver. Here's my config:
require'nvim_lsp'.diagnosticls.setup{
on_attach=on_attach_vim,
filetypes = { "sh", },
init_options = {
filetypes = {
sh = "shellcheck",
},
formatFiletypes = {
sh = "shfmt",
},
formatters = {
shfmt = {
command = "shfmt",
args = {
"-i",
"2",
"-bn",
"-ci",
"-sr",
},
}
},
linters = {
shellcheck = {
command = "shellcheck",
rootPatterns = {},
isStdout = true,
isStderr = false,
debounce = 100,
args = { "--format=gcc", "-"},
offsetLine = 0,
offsetColumn = 0,
sourceName = "shellcheck",
formatLines = 1,
formatPattern = {
"^([^:]+):(\\d+):(\\d+):\\s+([^:]+):\\s+(.*)$",
{
line = 2,
column = 3,
endline = 2,
endColumn = 3,
message = {5},
security = 4
}
},
securities = {
error ="error",
warning = "warning",
note = "info"
},
}
}
}
}
from diagnostic-languageserver.
You can see my current configuration here: https://github.com/walialu/neovimfiles/blob/e68391c1d98b3da2f8adfe1583f258a17295537b/nvim/lua/lsp_config.lua#L46
from diagnostic-languageserver.
This lsp config is pretty rough, but should work (thanks @lithammer):
nvim_lsp.diagnosticls.setup{
filetypes = { "javascript", "javascript.jsx" },
init_options = {
filetypes = {
javascript = "eslint",
["javascript.jsx"] = "eslint",
javascriptreact = "eslint",
typescriptreact = "eslint",
},
linters = {
eslint = {
sourceName = "eslint",
command = "./node_modules/.bin/eslint",
rootPatterns = { ".git" },
debounce = 100,
args = {
"--stdin",
"--stdin-filename",
"%filepath",
"--format",
"json",
},
parseJson = {
errorsRoot = "[0].messages",
line = "line",
column = "column",
endLine = "endLine",
endColumn = "endColumn",
message = "${message} [${ruleId}]",
security = "severity",
};
securities = {
[2] = "error",
[1] = "warning"
}
}
}
}
}
from diagnostic-languageserver.
in initializationOptions
option
from diagnostic-languageserver.
@thisguychris Where to config initializationOptions
options is relative to neovim's built-in LSP client. I do not use the built-in LSP client, so I have no idea. It should be support to config initializationOptions
for the LS.
from diagnostic-languageserver.
I'm using neivim's built-in LSP client, and I have a config as follows for checking shell scripts
local on_attach_vim = function(client)
require'completion'.on_attach(client)
require'diagnostic'.on_attach(client)
end
require'nvim_lsp'.diagnosticls.setup{
on_attach=on_attach_vim,
filetypes = { "sh", },
init_options = {
filetypes = {
sh = "shellcheck",
},
formatFiletypes = {
sh = "shfmt",
},
formatters = {
shfmt = {
command = "shfmt",
args = {
"-i",
"2",
"-bn",
"-ci",
"-sr",
},
}
}
}
}
I have the following plugins installed:
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'
Plug 'nvim-lua/diagnostic-nvim'
I open a shell script, nothing happens. Where am I supposed to find the diagnostic information?
from diagnostic-languageserver.
@smartding that config doesn't generate any diagnostics. I assume you want shellcheck
to provide diagnostics, but you don't actually provide it any linter config for it (you only have a formatter configured). I think you need to take a look at the README again for an example of how to configure a linter. You can also search for "diagnosticls shellcheck" on GitHub to find some examples.
from diagnostic-languageserver.
hey @iamcco, what I meant was, where do I put this JSON file, do I reference it somewhere in vimrc? I get that coc
has its own settings. I am more interested on how it's set up with just using neovim's built-in LSP?
from diagnostic-languageserver.
Hey @smartding, you need to config shellcheck to check your files. You can look at my configuration over here (this is how I configured shellcheck):
from diagnostic-languageserver.
@smartding Do you know how to show diagnostic messages from formatters like isort
?
from diagnostic-languageserver.
@nyngwang
No, I don't use isort.
from diagnostic-languageserver.
Related Issues (20)
- Split offsetColumn to offsetColumnStart and offsetColumnEnd
- How to populate quickfix list HOT 1
- clipboard: error -2 HOT 1
- How to register stylua as lua formatter ? HOT 3
- Applying multiple formatters in sequence HOT 1
- [feature] Add support for alex HOT 1
- [feature] Add support for vint's security HOT 1
- [feature] Add support for gitlint
- Suggested configuration for eslint and prettier not working HOT 5
- [Question] Add support for htmlhint
- How do I see the data that a linter is receiving? HOT 1
- [Question]: Exit Linter Daemon on Buffer Close
- Add config for gccdiag HOT 1
- Trying to set up erb-lint, how to use parseJson? HOT 2
- `security` -> `severity` HOT 2
- Does not run on arch: SyntaxError HOT 1
- Tree-sitter highlights group in comments are overriden HOT 2
- Support JSON lines output
- How to add sourcery as linter HOT 3
- Source Name is used wrong
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diagnostic-languageserver.