feat(neovim): update config

This commit is contained in:
Felix Schröter 2021-05-05 00:05:37 +02:00
parent 4dce40bbaa
commit a01676e247
No known key found for this signature in database
GPG key ID: 910ACB9F6BD26F58
7 changed files with 166 additions and 174 deletions

View file

@ -1,9 +1,9 @@
local config = require'lspconfig'
-- format on save
-- TODO often takes way longer to save than 1000 ms (e.g. 7000 ms in fitnesspilot-web)
local diagnosticls_on_attach = function(_, bufnr)
vim.api.nvim_command("au BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 1000)")
vim.api.nvim_command(
"au BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync(nil, nil, { 'tsserver', 'diagnosticls' })")
end
local pid = vim.fn.getpid()
@ -18,7 +18,7 @@ config.dockerls.setup{}
config.rnix.setup{}
config.tsserver.setup{}
config.omnisharp.setup{
cmd = {"omnisharp", "--languageserver", "--hostPID", tostring(pid)};
cmd = {"omnisharp", "--languageserver", "--hostPID", tostring(pid)},
}
config.pyls.setup{}
config.terraformls.setup{}
@ -27,126 +27,135 @@ config.hls.setup{}
-- based on: https://github.com/mikew/vimrc/blob/master/src/nvim/coc-settings.json
-- TODO breaks auto-completion when using with other lsp
-- TODO some ts projects are using tsc eslint plugin
-- config.diagnosticls.setup{
-- on_attach = diagnosticls_on_attach;
-- filetypes = {
-- "javascript",
-- "javascript.jsx",
-- "javascriptreact",
-- "typescript",
-- "typescript.jsx",
-- "typescriptreact",
-- "json",
-- "yaml",
-- "markdown",
-- "html",
-- "css"
-- };
-- init_options = {
-- linters = {
-- eslint = {
-- command = "eslint";
-- args = {
-- "--stdin",
-- "--stdin-filename",
-- "%filepath",
-- "--format",
-- "json"
-- };
-- rootPatterns = {".git"};
-- debounce = 50;
-- sourceName = "eslint";
-- parseJson = {
-- errorsRoot = "[0].messages";
-- line = "line";
-- column = "column";
-- endLine = "endLine";
-- endColumn = "endColumn";
-- message = "${message} [${ruleId}]";
-- security = "severity";
-- };
-- securities = {
-- ["2"] = "error";
-- ["1"] = "warning";
-- };
-- };
-- stylelint = {
-- command = "stylelint";
-- args = {
-- "--stdin",
-- "--formatter",
-- "json",
-- "--file",
-- "%filepath"
-- };
-- rootPatterns = {".git"};
-- debounce = 50;
-- sourceName = "stylelint";
-- parseJson = {
-- errorsRoot = "[0].warnings";
-- line = "line";
-- column = "column";
-- message = "${text}";
-- security = "severity";
-- };
-- securities = {
-- error = "error";
-- warning = "warning";
-- };
-- };
-- };
-- filetypes = {
-- javascript = {"eslint"};
-- ["javascript.jsx"] = {"eslint"};
-- javascriptreact = {"eslint"};
-- typescript = {"eslint"};
-- ["typescript.jsx"] = {"eslint"};
-- typescriptreact = {"eslint"};
-- css = {"stylelint"};
-- };
-- formatters = {
-- eslint = {
-- command = "eslint";
-- args = {
-- "--fix",
-- "%file"
-- };
-- rootPatterns = {".git"};
-- isStdout = 1;
-- doesWriteToFile = 1;
-- };
-- stylelint = {
-- command = "stylelint";
-- args = {
-- "--stdin",
-- "--fix",
-- "--file",
-- "%filepath"
-- };
-- rootPatterns = {".git"};
-- };
-- prettier = {
-- command = "prettier";
-- args = {
-- "--stdin",
-- "--stdin-filepath",
-- "%filepath"
-- };
-- rootPatterns = {".git"};
-- };
-- };
-- formatFiletypes = {
-- javascript = {"eslint"};
-- ["javascript.jsx"] = {"eslint"};
-- javascriptreact = {"eslint"};
-- typescript = {"eslint"};
-- ["typescript.jsx"] = {"eslint"};
-- typescriptreact = {"eslint"};
-- json = {"prettier"};
-- yaml = {"prettier"};
-- markdown = {"prettier"};
-- html = {"prettier"};
-- css = {"stylelint"};
-- };
-- };
-- }
config.diagnosticls.setup{
on_attach = diagnosticls_on_attach,
filetypes = {
"javascript",
"javascript.jsx",
"javascriptreact",
"typescript",
"typescript.jsx",
"typescriptreact",
"json",
"yaml",
"markdown",
"html",
"css"
},
init_options = {
linters = {
eslint = {
command = "eslint_d",
args = {
"--cache",
"--stdin",
"--stdin-filename",
"%filepath",
"--format",
"json"
},
rootPatterns = {".eslintrc.js", ".eslintrc.json", ".git"},
debounce = 50,
sourceName = "eslint",
parseJson = {
errorsRoot = "[0].messages",
line = "line",
column = "column",
endLine = "endLine",
endColumn = "endColumn",
message = "${message} [${ruleId}]",
security = "severity"
},
securities = {
["2"] = "error",
["1"] = "warning"
},
},
stylelint = {
command = "stylelint",
args = {
"--stdin",
"--formatter",
"json",
"--file",
"%filepath"
},
rootPatterns = {".git"},
debounce = 50,
sourceName = "stylelint",
parseJson = {
errorsRoot = "[0].warnings",
line = "line",
column = "column",
message = "${text}",
security = "severity",
},
securities = {
error = "error",
warning = "warning",
},
},
},
filetypes = {
javascript = {"eslint"},
["javascript.jsx"] = {"eslint"},
javascriptreact = {"eslint"},
typescript = {"eslint"},
["typescript.jsx"] = {"eslint"},
typescriptreact = {"eslint"},
css = {"stylelint"},
},
formatters = {
eslint = {
command = "eslint_d",
args = {
-- TODO eslint_d's stdin option doesn't work for some reason
-- "--cache",
-- "--fix-to-stdout",
-- "--stdin",
-- "--stdin-filename",
-- "%filepath"
"--cache",
"--fix",
"%filepath"
},
debounce = 50,
rootPatterns = {".eslintrc.js", ".eslintrc.json", ".git"},
isStdout = false,
doesWriteToFile = true,
},
stylelint = {
command = "stylelint",
args = {
"--stdin",
"--fix",
"--file",
"%filepath"
},
rootPatterns = {".stylelintrc.json", ".git"},
},
prettier = {
command = "prettier",
args = {
"--stdin",
"--stdin-filepath",
"%filepath"
},
rootPatterns = {".prettierrc.json", ".git"},
},
},
formatFiletypes = {
javascript = {"eslint"},
["javascript.jsx"] = {"eslint"},
javascriptreact = {"eslint"},
typescript = {"eslint"},
["typescript.jsx"] = {"eslint"},
typescriptreact = {"eslint"},
json = {"prettier"},
yaml = {"prettier"},
markdown = {"prettier"},
html = {"prettier"},
css = {"stylelint"},
},
},
}