a lot more stuff
This commit is contained in:
@ -1,18 +1,23 @@
|
||||
local misc = require('core.misc')
|
||||
local lsp = require('core.lsp.functions')
|
||||
local map, auto, augroup = misc.map, misc.auto, misc.augroup
|
||||
local map = misc.map
|
||||
|
||||
return { 'williamboman/mason-lspconfig.nvim',
|
||||
requires = {
|
||||
'williamboman/mason.nvim',
|
||||
{ 'neovim/nvim-lspconfig',
|
||||
disable = vim.version().minor < 8,
|
||||
disable = not vim.fn.has("nvim-0.8.0"),
|
||||
function()
|
||||
lsp.setup()
|
||||
end
|
||||
}
|
||||
},
|
||||
|
||||
-- these two update some lsp capabilities and therefore must be run first
|
||||
-- 'hrsh7th/cmp-nvim-lsp',
|
||||
-- 'kevinhwang91/nvim-ufo'
|
||||
},
|
||||
function()
|
||||
local lspconfig = require('lspconfig')
|
||||
local util = require('lspconfig.util')
|
||||
|
||||
-- setup language servers
|
||||
@ -27,97 +32,105 @@ return { 'williamboman/mason-lspconfig.nvim',
|
||||
"bashls",
|
||||
"zls"
|
||||
-- "asm-lsp", -- seems to be broken
|
||||
}
|
||||
}
|
||||
require('mason-lspconfig').setup_handlers {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
on_attach = lsp.lsp_attach,
|
||||
capabilities = lsp.capabilities()
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- setup luals
|
||||
["lua_ls"] = function(server_name)
|
||||
local root_files = { '.luarc.json', '.luarc.jsonc', '.luacheckrc',
|
||||
'.stylua.toml', 'stylua.toml', 'selene.toml', 'selene.yml',
|
||||
'README.md'
|
||||
}
|
||||
-- setup all handlers
|
||||
handlers = {
|
||||
function(server_name)
|
||||
lspconfig[server_name].setup {}
|
||||
end,
|
||||
|
||||
-- FIXME: luals seems to start up twice and sends back twice the
|
||||
-- completions (one configured with the below settings and one without)
|
||||
require('lspconfig')[server_name].setup {
|
||||
on_attach = lsp.attach,
|
||||
capabilities = lsp.capabilities(),
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim", 'mp' }
|
||||
},
|
||||
runtime = {
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
format = {
|
||||
enable = false
|
||||
},
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
-- setup luals
|
||||
["lua_ls"] = function(server_name)
|
||||
local root_files = { '.luarc.json', '.luarc.jsonc', '.luacheckrc',
|
||||
'.stylua.toml', 'stylua.toml', 'selene.toml', 'selene.yml',
|
||||
'README.md'
|
||||
}
|
||||
|
||||
-- FIXME: luals seems to start up twice and sends back twice the
|
||||
-- completions (one configured with the below settings and one without)
|
||||
lspconfig[server_name].setup {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim", 'mp' }
|
||||
},
|
||||
runtime = {
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
format = {
|
||||
enable = false
|
||||
},
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
root_dir = function(fname)
|
||||
local root = util.root_pattern(unpack(root_files))(fname)
|
||||
if root and root ~= vim.env.HOME then
|
||||
return root
|
||||
root_dir = function(fname)
|
||||
local root = util.root_pattern(unpack(root_files))(fname)
|
||||
if root and root ~= vim.env.HOME then
|
||||
return root
|
||||
end
|
||||
|
||||
root = util.root_pattern('lua/')(fname)
|
||||
if root then
|
||||
return root
|
||||
end
|
||||
return util.find_git_ancestor(fname)
|
||||
end
|
||||
}
|
||||
end,
|
||||
|
||||
root = util.root_pattern('lua/')(fname)
|
||||
if root then
|
||||
return root
|
||||
end
|
||||
return util.find_git_ancestor(fname)
|
||||
end
|
||||
}
|
||||
end,
|
||||
-- setup clangd
|
||||
["clangd"] = function(server_name)
|
||||
lspconfig[server_name].setup {
|
||||
on_attach = function(client, bufnr)
|
||||
-- add some clangd specific mappings
|
||||
local opts = { buffer = bufnr }
|
||||
map("n", "<leader>o", "<cmd>ClangdSwitchSourceHeader<CR>", opts)
|
||||
end,
|
||||
|
||||
-- setup clangd
|
||||
["clangd"] = function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
on_attach = function(client, bufnr)
|
||||
lsp.attach(client, bufnr)
|
||||
|
||||
-- add some clangd specific mappings
|
||||
local opts = { buffer = bufnr }
|
||||
map("n", "<leader>o", "<cmd>ClangdSwitchSourceHeader<CR>", opts)
|
||||
end,
|
||||
capabilities = lsp.capabilities(),
|
||||
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--header-insertion=iwyu",
|
||||
"--completion-style=detailed",
|
||||
"--function-arg-placeholders",
|
||||
"--fallback-style=llvm"
|
||||
},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
clangdFileStatus = true,
|
||||
fallback_flags = {
|
||||
"-xc" -- makes clangd think we're using c instead of c++
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--header-insertion=iwyu",
|
||||
"--completion-style=detailed",
|
||||
"--function-arg-placeholders",
|
||||
"--fallback-style=llvm"
|
||||
},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
clangdFileStatus = true,
|
||||
fallback_flags = {
|
||||
"-xc" -- makes clangd think we're using c instead of c++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end,
|
||||
end,
|
||||
|
||||
-- disable it, we start this using nvim-jdtls
|
||||
["jdtls"] = function(_) end
|
||||
-- disable it, we start this using nvim-jdtls
|
||||
["jdtls"] = function(_) end,
|
||||
|
||||
-- setup basedpyright
|
||||
["basedpyright"] = function(server_name)
|
||||
lspconfig[server_name].setup {
|
||||
on_attach = function(client, bufnr)
|
||||
-- add some basedpyright specific mappings
|
||||
local opts = { buffer = bufnr }
|
||||
map("n", "cri", "<cmd>PyrightOrganizeImports<CR>", opts)
|
||||
end,
|
||||
}
|
||||
end
|
||||
},
|
||||
|
||||
["openscad_lsp"] = function(server_name)
|
||||
lspconfig[server_name].setup {}
|
||||
end
|
||||
}
|
||||
|
||||
end
|
||||
}
|
||||
|
Reference in New Issue
Block a user