neovim: lsp: add eslint language server

This commit is contained in:
FollieHiyuki 2021-10-20 01:57:38 +07:00
parent b3d7a24c19
commit 265c64ae4a
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
2 changed files with 38 additions and 12 deletions

View File

@ -1,4 +1,3 @@
-- TODO: eslint language server
local M = {} local M = {}
function M.lsp_conf() function M.lsp_conf()
@ -229,6 +228,42 @@ function M.lsp_conf()
filetypes = {'html', 'markdown'} filetypes = {'html', 'markdown'}
} }
-- Eslint
lspconf.eslint.setup {
on_attach = on_attach,
capabilities = capabilities,
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-eslint-language-server', '--stdio'},
filetypes = {'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'vue', 'svelte'},
handlers = {
['eslint/noConfig'] = function()
vim.notify('Unable to parse ESLint config.', vim.log.levels.WARN)
end
},
settings = {
codeAction = {
disableRuleComment = {
enable = true,
location = 'separateLine'
},
showDocumentation = {enable = true}
},
codeActionOnSave = {
enable = false, -- run ':EslintFixAll' manually
mode = 'all'
},
format = true,
nodePath = '',
onIgnoredFiles = 'off',
packageManager = 'npm',
quiet = false,
rulesCustomizations = {},
run = 'onType',
useESLintClass = false,
validate = 'on',
workingDirectory = {mode = 'auto'}
}
}
-- JSON -- JSON
lspconf.jsonls.setup { lspconf.jsonls.setup {
on_attach = on_attach, on_attach = on_attach,
@ -316,12 +351,6 @@ function M.lsp_conf()
-- null_ls.builtins.formatting.cmake_format.with { -- null_ls.builtins.formatting.cmake_format.with {
-- command = 'cmake-format' -- command = 'cmake-format'
-- }, -- },
-- null_ls.builtins.formatting.eslint.with {
-- condition = function(utils)
-- return utils.root_has_file('.eslintrc.js')
-- end,
-- command = 'eslint'
-- },
null_ls.builtins.formatting.fish_indent, null_ls.builtins.formatting.fish_indent,
-- null_ls.builtins.formatting.fixjson.with { -- null_ls.builtins.formatting.fixjson.with {
-- command = 'fixjson' -- command = 'fixjson'
@ -374,9 +403,6 @@ function M.lsp_conf()
-- null_ls.builtins.diagnostics.codespell.with { -- null_ls.builtins.diagnostics.codespell.with {
-- command = 'codespell' -- command = 'codespell'
-- }, -- },
-- null_ls.builtins.diagnostics.eslint.with {
-- command = 'eslint'
-- },
-- null_ls.builtins.diagnostics.flake8.with { -- null_ls.builtins.diagnostics.flake8.with {
-- command = 'flake8' -- command = 'flake8'
-- }, -- },

View File

@ -2,7 +2,7 @@
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo "Usage:" echo "Usage:"
printf " - %s server_name: install specified server\n" "$0" printf " - %s [server_name]: install specified server\n" "$0"
printf " - %s -lsp: install all lsp servers\n" "$0" printf " - %s -lsp: install all lsp servers\n" "$0"
printf " - %s -dap: install all dap servers\n" "$0" printf " - %s -dap: install all dap servers\n" "$0"
printf " - %s -lint: install everything\n" "$0" printf " - %s -lint: install everything\n" "$0"
@ -27,7 +27,7 @@ else
# Each server should have an unique name # Each server should have an unique name
server_path=$(find "${nvim_script_dir}" -mindepth 2 -type f -name "$1" | head -n 1) server_path=$(find "${nvim_script_dir}" -mindepth 2 -type f -name "$1" | head -n 1)
if [ -z "${server_path}" ]; then if [ -z "${server_path}" ]; then
echo "Incorrect server name $1" printf "Incorrect server name \033[1;31m%s\033[0m.\n" "$1"
exit 1 exit 1
fi fi
printf "\033[1;34mInstalling \033[1;32m%s\033[1;34m...\033[0m\n" "$1" printf "\033[1;34mInstalling \033[1;32m%s\033[1;34m...\033[0m\n" "$1"