You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
3.2 KiB
141 lines
3.2 KiB
--INFO: Setup various LSP servers, and completion engines
|
|
--TODO: use nvim-lsp-installer?
|
|
local cmp = require('cmp')
|
|
local lspconfig = require('lspconfig')
|
|
local configs = require('lspconfig.configs')
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn['vsnip#anonymous'](args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
['<Tab>'] = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
},
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'nvim_lua' },
|
|
{ name = 'vsnip' },
|
|
--{ name = 'buffer' },
|
|
}),
|
|
})
|
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
|
|
if not configs.astrols then
|
|
configs.astrols = {
|
|
default_config = {
|
|
cmd = { 'astro-ls', '--stdio' },
|
|
filetypes = { 'astro' },
|
|
root_dir = function(fname)
|
|
return lspconfig.util.find_node_modules_ancestor(fname)
|
|
end,
|
|
init_options = {
|
|
astro = {
|
|
enabled = true,
|
|
diagnostics = { enabled = true },
|
|
rename = { enabled = true },
|
|
format = { enabled = true },
|
|
completions = { enabled = true },
|
|
hover = { enabled = true },
|
|
codeActions = { enabled = true },
|
|
selectionRange = { enabled = true },
|
|
},
|
|
},
|
|
},
|
|
}
|
|
end
|
|
|
|
--lspconfig.astrols.setup({
|
|
-- capabilities = capabilities,
|
|
--})
|
|
|
|
require('lspconfig').clangd.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
--require('lspconfig').denols.setup({
|
|
-- cmd = { 'deno', 'lsp' },
|
|
-- capabilities = capabilities,
|
|
--})
|
|
|
|
require('lspconfig').vls.setup({
|
|
cmd = { '/usr/local/bin/vls' },
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
require('lspconfig').pyright.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
require('lspconfig').zls.setup({
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
local function arrayHasVal(tab, val)
|
|
for index, value in ipairs(tab) do
|
|
if value == val then
|
|
return true
|
|
end
|
|
end
|
|
|
|
return false
|
|
end
|
|
local checkTsDiagnosticsCodes = function(_, _, params, client_id, _, config)
|
|
local codesToIgnore = { 8010, 8011 }
|
|
if params.diagnostics ~= nil then
|
|
local idx = 1
|
|
while idx <= #params.diagnostics do
|
|
if arrayHasVal(codesToIgnore, params.diagnostics[idx].code) then
|
|
table.remove(params.diagnostics, idx)
|
|
else
|
|
idx = idx + 1
|
|
end
|
|
end
|
|
vim.lsp.diagnostic.on_publish_diagnostics(_, _, params, client_id, _, config)
|
|
end
|
|
end
|
|
--require('lspconfig').tsserver.setup({
|
|
-- capabilities = capabilities,
|
|
--})
|
|
|
|
require('lspconfig').flow.setup({
|
|
cmd = { 'flow', 'lsp' },
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
--TODO: clean this up
|
|
local runtime_path = vim.split(package.path, ';')
|
|
table.insert(runtime_path, 'lua/?.lua')
|
|
table.insert(runtime_path, 'lua/?/init.lua')
|
|
local sumneko_root_path = '/home/ruthenic/lua-language-server/bin/Linux/'
|
|
require('lspconfig').sumneko_lua.setup({
|
|
cmd = { sumneko_root_path .. 'lua-language-server', '-E', sumneko_root_path .. 'main.lua' },
|
|
settings = {
|
|
Lua = {
|
|
runtime = {
|
|
version = 'LuaJIT',
|
|
path = runtime_path,
|
|
},
|
|
diagnostics = {
|
|
globals = { 'vim', 'use' },
|
|
},
|
|
workspace = {
|
|
library = vim.api.nvim_get_runtime_file('', true),
|
|
},
|
|
telemetry = {
|
|
enable = false,
|
|
},
|
|
},
|
|
},
|
|
capabilities = capabilities,
|
|
})
|