279 lines
8.2 KiB
Lua
279 lines
8.2 KiB
Lua
local servers_path = vim.fn.stdpath('data') .. '/lsp'
|
|
local lspconf = require('lspconfig')
|
|
local util = require('modules.lsp.util')
|
|
local on_attach = util.common_on_attach
|
|
local capabilities = util.common_capabilities()
|
|
|
|
local border = {
|
|
{'┌', 'FloatBorder'},
|
|
{'─', 'FloatBorder'},
|
|
{'┐', 'FloatBorder'},
|
|
{'│', 'FloatBorder'},
|
|
{'┘', 'FloatBorder'},
|
|
{'─', 'FloatBorder'},
|
|
{'└', 'FloatBorder'},
|
|
{'│', 'FloatBorder'}
|
|
}
|
|
|
|
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
|
border = border,
|
|
})
|
|
|
|
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
|
border = border,
|
|
})
|
|
|
|
vim.diagnostic.config({
|
|
virtual_text = {
|
|
prefix = '■',
|
|
-- source = 'always'
|
|
},
|
|
signs = {
|
|
active = true,
|
|
values = {
|
|
{name = 'DiagnosticsSignError', text = ''},
|
|
{name = 'DiagnosticsSignWarning', text = ''},
|
|
{name = 'DiagnosticsSignInformation', text = ''},
|
|
{name = 'DiagnosticsSignHint', text = ''}
|
|
}
|
|
},
|
|
update_in_insert = false,
|
|
severity_sort = true
|
|
})
|
|
|
|
-----------------------------
|
|
-- Servers' configurations --
|
|
-----------------------------
|
|
lspconf.clangd.setup {
|
|
filetypes = {'c', 'cpp'},
|
|
init_options = {
|
|
usePlaceholders = true,
|
|
completeUnimported = true,
|
|
clangdFileStatus = true
|
|
},
|
|
cmd = {
|
|
'clangd',
|
|
'-j=2',
|
|
'--background-index',
|
|
'--clang-tidy',
|
|
'--completion-style=detailed',
|
|
'--pch-storage=memory',
|
|
'--header-insertion=iwyu',
|
|
'--header-insertion-decorators'
|
|
},
|
|
on_attach = on_attach,
|
|
capabilities = capabilities
|
|
}
|
|
|
|
lspconf.sumneko_lua.setup {
|
|
cmd = {
|
|
servers_path .. '/sumneko_lua/bin/Linux/lua-language-server',
|
|
'-E', '-e', 'LANG=en',
|
|
servers_path .. '/sumneko_lua/main.lua'
|
|
},
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {globals = {'vim'}},
|
|
runtime = {version = 'LuaJIT', path = util.lua_runtime_path()},
|
|
workspace = {
|
|
library = util.lua_lib_path(),
|
|
maxPreload = 1000,
|
|
preloadFileSize = 150
|
|
},
|
|
completion = {callSnippet = 'Replace'},
|
|
hint = {enable = true},
|
|
telemetry = {enable = false}
|
|
}
|
|
}
|
|
}
|
|
|
|
lspconf.pylsp.setup {
|
|
cmd = {vim.fn.stdpath('config') .. '/scripts/pylsp'},
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
pylsp = {
|
|
-- configurationSources = {'pycodestyle', 'flake8'},
|
|
plugins = {
|
|
-- flake8 = {
|
|
-- enabled = true,
|
|
-- executable = servers_path .. 'pylsp/venv/bin/flake8'
|
|
-- },
|
|
mccabe = {
|
|
enabled = true,
|
|
threshold = 15
|
|
},
|
|
pycodestyle = {enabled = true},
|
|
-- pydocstyle = {enabled = true},
|
|
pyflakes = {enabled = true},
|
|
-- pylint = {
|
|
-- enabled = true,
|
|
-- executable = servers_path .. 'pylsp/venv/bin/pylint'
|
|
-- },
|
|
rope_completion = {
|
|
enabled = true,
|
|
eager = false
|
|
},
|
|
yapf = {enabled = true}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
lspconf.gopls.setup {
|
|
cmd = {servers_path .. '/gopls/gopls', '--remote=auto'},
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
init_options = {
|
|
usePlaceholders = true,
|
|
completeUnimported = true
|
|
}
|
|
}
|
|
|
|
-- lspconf.yamlls.setup {
|
|
-- cmd = {servers_path .. '/yamlls/node_modules/.bin/yaml-language-server', '--stdio'},
|
|
-- on_attach = on_attach,
|
|
-- capabilities = capabilities,
|
|
-- settings = {
|
|
-- redhat = {telemetry = {enabled = false}},
|
|
-- yaml = {
|
|
-- format = {
|
|
-- bracketSpacing = true,
|
|
-- printWidth = 80,
|
|
-- -- proseWrap = 'always', -- default is 'preserve'
|
|
-- -- singleQuote = true,
|
|
-- -- editor.formatOnType = true
|
|
-- },
|
|
-- schemas = require('schemastore').json.schemas()
|
|
-- }
|
|
-- }
|
|
-- }
|
|
|
|
lspconf.ansiblels.setup {
|
|
cmd = {'node', servers_path .. '/ansiblels/out/server/src/server.js', '--stdio'},
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
ansible = {
|
|
python = {interpreterPath = 'python3'},
|
|
executionEnvironment = {enabled = false}
|
|
}
|
|
}
|
|
}
|
|
|
|
-- lspconf.tailwindcss.setup {
|
|
-- cmd = {servers_path .. '/tailwindcss/node_modules/.bin/tailwindcss-language-server', '--stdio'},
|
|
-- on_attach = on_attach,
|
|
-- capabilities = capabilities,
|
|
-- settings = {
|
|
-- tailwindCSS = {
|
|
-- emmetCompletions = true
|
|
-- }
|
|
-- }
|
|
-- }
|
|
|
|
lspconf.emmet_ls.setup {
|
|
cmd = {servers_path .. '/emmet_ls/node_modules/.bin/emmet-ls', '--stdio'},
|
|
capabilities = capabilities,
|
|
filetypes = {
|
|
'html', 'xml', 'css', 'scss', 'sass',
|
|
'javascript', 'javascriptreact'
|
|
},
|
|
}
|
|
|
|
lspconf.eslint.setup {
|
|
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-eslint-language-server', '--stdio'},
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
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'}
|
|
}
|
|
}
|
|
|
|
lspconf.jsonls.setup {
|
|
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-json-language-server', '--stdio'},
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
json = {
|
|
-- Schema catalog: https://www.schemastore.org/api/json/catalog.json
|
|
schemas = require('schemastore').json.schemas()
|
|
}
|
|
}
|
|
}
|
|
|
|
lspconf.rust_analyzer.setup {
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
['rust-analyzer'] = {
|
|
checkOnSave = {
|
|
enable = true,
|
|
command = 'clippy'
|
|
},
|
|
callInfo = {full = true},
|
|
lens = {
|
|
enable = true,
|
|
references = true,
|
|
implementations = true,
|
|
enumVariantReferences = true,
|
|
methodReferences = true
|
|
},
|
|
inlayHints = {
|
|
enable = true,
|
|
typeHints = true,
|
|
parameterHints = true
|
|
},
|
|
hoverActions = {enable = true},
|
|
cargo = {autoreload = true}
|
|
}
|
|
}
|
|
}
|
|
|
|
local servers = {
|
|
sqls = {servers_path .. '/sqls/sqls'},
|
|
cmake = {servers_path .. '/cmake/venv/bin/cmake-language-server'},
|
|
-- bashls = {servers_path .. '/bashls/node_modules/.bin/bash-language-server', 'start'},
|
|
-- dockerls = {servers_path .. '/dockerls/node_modules/.bin/docker-langserver', '--stdio'},
|
|
html = {servers_path .. '/vscode/node_modules/.bin/vscode-html-language-server', '--stdio'},
|
|
cssls = {servers_path .. '/vscode/node_modules/.bin/vscode-css-language-server', '--stdio'},
|
|
-- vimls = {servers_path .. '/vimls/node_modules/.bin/vim-language-server', '--stdio'},
|
|
tsserver = {servers_path .. '/tsserver/node_modules/.bin/typescript-language-server', '--stdio'}
|
|
}
|
|
|
|
for server, _ in pairs(servers) do
|
|
lspconf[server].setup {
|
|
cmd = servers[server],
|
|
on_attach = on_attach,
|
|
capabilities = capabilities
|
|
}
|
|
end
|