mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
feat!(nvim): Migrate to v0.11 built-in lsp configs
This commit is contained in:
parent
4da1667c54
commit
9315c6e55d
16 changed files with 303 additions and 31 deletions
15
tools/nvim/lsp/bashls.lua
Normal file
15
tools/nvim/lsp/bashls.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- Bash
|
||||
--[[ Installation
|
||||
brew install bash-language-server
|
||||
npm i -g bash-language-server
|
||||
dnf install -y nodejs-bash-language-server # Fedora Linux
|
||||
--]]
|
||||
return {
|
||||
cmd = { "bash-language-server", "start" },
|
||||
filetypes = { "bash", "sh" },
|
||||
settings = {
|
||||
bashIde = {
|
||||
globPattern = vim.env.GLOB_PATTERN or "*@(.sh|.inc|.bash|.command)",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,5 +1,30 @@
|
|||
-- C/C++
|
||||
-- Clangd requires compile_commands.json to work and the easiest way to generate it is to use CMake.
|
||||
-- How to use clangd C/C++ LSP in any project: https://gist.github.com/Strus/042a92a00070a943053006bf46912ae9
|
||||
|
||||
return {
|
||||
cmd = { "clangd", "--background-index" },
|
||||
root_markers = { "compile_commands.json", "compile_flags.txt", ".clangd" },
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--clang-tidy",
|
||||
"--header-insertion=iwyu",
|
||||
"--completion-style=detailed",
|
||||
"--function-arg-placeholders",
|
||||
"--fallback-style=none",
|
||||
},
|
||||
filetypes = { "c", "cpp" },
|
||||
root_markers = {
|
||||
".clangd",
|
||||
".clang-format",
|
||||
"compile_commands.json",
|
||||
"compile_flags.txt",
|
||||
".git",
|
||||
},
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
editsNearCursor = true,
|
||||
},
|
||||
},
|
||||
offsetEncoding = { "utf-8", "utf-16" },
|
||||
},
|
||||
}
|
||||
|
|
|
|||
19
tools/nvim/lsp/gopls.lua
Normal file
19
tools/nvim/lsp/gopls.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
-- Golang
|
||||
--[[ Installation
|
||||
go install golang.org/x/tools/gopls@latest
|
||||
brew install gopls
|
||||
--]]
|
||||
return {
|
||||
cmd = { "gopls" },
|
||||
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
||||
root_markers = { "go.work", "go.mod", ".git" },
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
-- semanticTokens = true, -- go's semantic token highlight is not accurate so far
|
||||
},
|
||||
},
|
||||
}
|
||||
18
tools/nvim/lsp/jsonls.lua
Normal file
18
tools/nvim/lsp/jsonls.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-- JSON
|
||||
--[[
|
||||
npm i vscode-json-languageserver
|
||||
--]]
|
||||
return {
|
||||
cmd = { "vscode-json-language-server", "--stdio" },
|
||||
filetypes = { "json", "jsonc" },
|
||||
root_markers = { ".git" },
|
||||
init_options = {
|
||||
provideFormatter = true,
|
||||
},
|
||||
settings = {
|
||||
-- See setting options
|
||||
-- https://github.com/microsoft/vscode/tree/main/extensions/json-language-features/server#settings
|
||||
json = {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1 +1,37 @@
|
|||
return {}
|
||||
-- Lua
|
||||
--[[ Installation
|
||||
scoop install lua-language-server
|
||||
brew install lua-language-server
|
||||
sudo port install lua-language-server
|
||||
--]]
|
||||
--[[ Build: Ninja & C++17 Required
|
||||
git clone https://github.com/LuaLS/lua-language-server --depth 1
|
||||
cd lua-language-server
|
||||
./make.sh
|
||||
--]]
|
||||
--[[ Note: For building from source, wrapper script is required
|
||||
Accompanied with a wrapper script
|
||||
#!/bin/bash
|
||||
exec "$HOME/.local/build/lua-language-server/bin/lua-language-server" "$@"
|
||||
--]]
|
||||
return {
|
||||
cmd = { "lua-language-server" },
|
||||
root_markers = {
|
||||
".luarc.json",
|
||||
".luarc.jsonc",
|
||||
".luacheckrc",
|
||||
".stylua.toml",
|
||||
"stylua.toml",
|
||||
"selene.toml",
|
||||
"selene.yml",
|
||||
},
|
||||
filetypes = { "lua" },
|
||||
settings = {
|
||||
Lua = {
|
||||
hint = {
|
||||
enable = true,
|
||||
setType = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
27
tools/nvim/lsp/pyright.lua
Normal file
27
tools/nvim/lsp/pyright.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-- Python
|
||||
--[[ Installation
|
||||
uv tool install pyright
|
||||
--]]
|
||||
return {
|
||||
cmd = { "pyright-langserver", "--stdio" },
|
||||
filetypes = { "python" },
|
||||
root_markers = {
|
||||
".python_version",
|
||||
"pyproject.toml",
|
||||
"setup.py",
|
||||
"setup.cfg",
|
||||
"requirements.txt",
|
||||
"Pipfile",
|
||||
"pyrightconfig.json",
|
||||
".git",
|
||||
},
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
diagnosticMode = "openFilesOnly",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
33
tools/nvim/lsp/rust_analyzer.lua
Normal file
33
tools/nvim/lsp/rust_analyzer.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
-- Rust
|
||||
--[[ Installation
|
||||
rustup component add rust-src
|
||||
--]]
|
||||
return {
|
||||
cmd = { "rust-analyzer" },
|
||||
filetypes = { "rust" },
|
||||
root_dir = function(bufnr, cb)
|
||||
local root = vim.fs.root(bufnr, { "Cargo.toml" })
|
||||
if root then
|
||||
vim.system({ "cargo", "metadata", "--no-depts", "--format-version", "1" }, { cwd = root }, function(obj)
|
||||
if obj.code ~= 0 then
|
||||
cb(root)
|
||||
else
|
||||
local success, result = pcall(vim.json.decode, obj.stdout)
|
||||
if success and result.workspace_root then
|
||||
cb(result.workspace_root)
|
||||
else
|
||||
cb(root)
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
cb(vim.fs.root(bufnr, { "rust-project.json", ".git" }))
|
||||
end
|
||||
end,
|
||||
before_init = function(init_params, config)
|
||||
-- See https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26
|
||||
if config.settings and config.settings["rust-analyzer"] then
|
||||
init_params.initializationOptions = config.settings["rust-analyzer"]
|
||||
end
|
||||
end,
|
||||
}
|
||||
32
tools/nvim/lsp/taplo.lua
Normal file
32
tools/nvim/lsp/taplo.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
-- TOML
|
||||
--[[ Installation
|
||||
cargo install taplo-cli --locked
|
||||
brew install taplo
|
||||
pnpm install -g @taplo/cli
|
||||
--]]
|
||||
return {
|
||||
cmd = { "taplo", "lsp", "stdio" },
|
||||
filetypes = { "toml" },
|
||||
root_markers = { ".git" },
|
||||
settings = {
|
||||
-- See all the setting options
|
||||
-- https://github.com/tamasfe/taplo/blob/master/editors/vscode/package.json
|
||||
evenBetterToml = {
|
||||
taplo = {
|
||||
configFile = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
schema = {
|
||||
enabled = true,
|
||||
catalogs = {
|
||||
"https://www.schemastore.org/api/json/catalog.json",
|
||||
},
|
||||
cache = {
|
||||
memoryExpiration = 60,
|
||||
diskExpiration = 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
19
tools/nvim/lsp/vimls.lua
Normal file
19
tools/nvim/lsp/vimls.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
return {
|
||||
cmd = { "vim-language-server", "--stdio" },
|
||||
filetypes = { "vim" },
|
||||
root_markers = { ".git" },
|
||||
init_options = {
|
||||
isNeovim = true,
|
||||
iskeyword = "@,48-57,_,192-255,-#",
|
||||
vimruntime = "",
|
||||
runtimepath = "",
|
||||
diagnostic = { enable = true },
|
||||
indexes = {
|
||||
runtimepath = true,
|
||||
gap = 100,
|
||||
count = 3,
|
||||
projectRootPatterns = { "runtime", "nvim", ".git", "autoload", "plugin" },
|
||||
},
|
||||
suggest = { fromVimruntime = true, fromRuntimepath = true },
|
||||
},
|
||||
}
|
||||
9
tools/nvim/lsp/yamlls.lua
Normal file
9
tools/nvim/lsp/yamlls.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
return {
|
||||
cmd = { "yaml-language-server", "--stdio" },
|
||||
filetypes = { "yaml", "yaml.docker-compose", "yaml.gitlab" },
|
||||
root_markers = { ".git" },
|
||||
settings = {
|
||||
yaml = {
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue