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
31
Justfile
31
Justfile
|
|
@ -1,8 +1,9 @@
|
|||
set shell := ["fish", "-c"]
|
||||
# set shell := ["fish", "-c"]
|
||||
set shell := ["bash", "-c"]
|
||||
set windows-shell := ["pwsh", "-c"]
|
||||
|
||||
|
||||
PLATFORM := \
|
||||
OS := \
|
||||
if os() == "linux" {
|
||||
if env("WSL_DISTRO_NAME","") != "" {
|
||||
"wsl"
|
||||
|
|
@ -93,7 +94,7 @@ vivaldi:
|
|||
|
||||
[linux]
|
||||
systemd:
|
||||
ln -sf {{DOTFILES}}/platforms/{{PLATFORM}}/systemd {{XDG_CONFIG_HOME}}/systemd/
|
||||
ln -sf {{DOTFILES}}/platforms/{{OS}}/systemd {{XDG_CONFIG_HOME}}/systemd/
|
||||
|
||||
|
||||
uv:
|
||||
|
|
@ -129,6 +130,12 @@ neovim:
|
|||
{{LN}} {{DOTFILES}}/tools/nvim {{XDG_CONFIG_HOME}}/nvim
|
||||
nvim --headless +checkhealth +"w nvim-healthcheck.txt" +qall
|
||||
|
||||
[unix]
|
||||
neovide:
|
||||
which neovide
|
||||
-mkdir -p {{XDG_CONFIG_HOME}}/neovide
|
||||
{{LN}} {{DOTFILES}}/platforms/{{OS}}/neovide.toml {{XDG_CONFIG_HOME}}/neovide/config.toml
|
||||
|
||||
[unix]
|
||||
thunderbird:
|
||||
curl -L https://github.com/wshanks/tbkeys/releases/download/v2.4.0/tbkeys.xpi -o "$HOME/Downloads/tbkeys.xpi"
|
||||
|
|
@ -168,6 +175,24 @@ kitty:
|
|||
zotero:
|
||||
curl -L https://github.com/syt2/zotero-addons/releases/download/V1.8.1/zotero-addons.xpi -o "$HOME/Downloads/zotero-addons.xpi"
|
||||
|
||||
[unix]
|
||||
fish:
|
||||
{{LN}} {{DOTFILES}}/tools/fish {{XDG_CONFIG_HOME}}/fish
|
||||
curl -L https://raw.githubusercontent.com/SpaceAceMonkey/dotenv-for-fish/refs/heads/main/dotenv.fish -o "{{DOTFILES}}/tools/fish/functions/dotenv.fish"
|
||||
|
||||
|
||||
[unix]
|
||||
zsh:
|
||||
-[[ -f /etc/zshenv ]] && sudo cp {{DOTFILES}}/tools/zsh/global.zshenv /etc/zshenv # or /etc/zsh/zshenv
|
||||
-[[ -f /etc/zsh/zshenv ]] && sudo cp {{DOTFILES}}/tools/zsh/global.zshenv /etc/zsh/zshenv
|
||||
mkdir -p {{XDG_CONFIG_HOME}}/zsh
|
||||
{{LN}} {{DOTFILES}}/tools/zsh/zshenv {{XDG_CONFIG_HOME}}/zsh/.zshenv
|
||||
{{LN}} {{DOTFILES}}/tools/zsh/zshrc {{XDG_CONFIG_HOME}}/zsh/.zshrc
|
||||
{{LN}} {{DOTFILES}}/tools/zsh/zprofile {{XDG_CONFIG_HOME}}/zsh/.zprofile
|
||||
test -d {{XDG_CONFIG_HOME}}/zsh/plugins/zsh-autosuggestions || git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions.git {{XDG_CONFIG_HOME}}/zsh/plugins/zsh-autosuggestions
|
||||
test -d {{XDG_CONFIG_HOME}}/zsh/plugins/zsh-syntax-highlighting || git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git {{XDG_CONFIG_HOME}}/zsh/plugins/zsh-syntax-highlighting
|
||||
test -d {{XDG_CONFIG_HOME}}/zsh/plugins/zsh-history-substring-search || git clone --depth 1 https://github.com/zsh-users/zsh-history-substring-search.git {{XDG_CONFIG_HOME}}/zsh/plugins/zsh-history-substring-search
|
||||
test -d {{XDG_CONFIG_HOME}}/zsh/plugins/zsh-completions || git clone --depth 1 https://github.com/zsh-users/zsh-completions.git {{XDG_CONFIG_HOME}}/zsh/plugins/zsh-completions
|
||||
|
||||
[linux]
|
||||
flatpak:
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ else -- Vanilla neovim
|
|||
end
|
||||
require("config.keymaps")
|
||||
require("config.diagnostics")
|
||||
require("config.migration")
|
||||
|
||||
-- If current session is spawn by neovide, do:
|
||||
if vim.g.neovide then
|
||||
|
|
|
|||
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 = {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,14 +1,31 @@
|
|||
local nvim_version = vim.version()
|
||||
|
||||
|
||||
if nvim_version.minor ~= 11 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_lines = true,
|
||||
})
|
||||
|
||||
vim.lsp.enable({
|
||||
"clangd",
|
||||
"luals",
|
||||
})
|
||||
-- vim.lsp.enable({
|
||||
-- "clangd",
|
||||
-- "luals",
|
||||
-- })
|
||||
|
||||
local lsp_configs = {}
|
||||
for _, v in ipairs(vim.api.nvim_get_runtime_file('lsp/*', true)) do
|
||||
local name = vim.fn.fnamemodify(v, ':t:r')
|
||||
lsp_configs[name] = true
|
||||
end
|
||||
|
||||
vim.lsp.enable(vim.tbl_keys(lsp_configs))
|
||||
|
||||
-- Delete 0.11 new gr- keymaps
|
||||
vim.keymap.del({ "n" }, "grn")
|
||||
vim.keymap.del({ "n", "x" }, "gra")
|
||||
vim.keymap.del({ "n" }, "gri")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
return {
|
||||
{ import = "plugins.mod.nvim-lspconfig" },
|
||||
-- { import = "plugins.mod.nvim-lspconfig" },
|
||||
{
|
||||
"lervag/vimtex",
|
||||
ft = { "tex", "bib" },
|
||||
|
|
@ -27,18 +27,18 @@ return {
|
|||
-- ensure_installed = require("config.servers").servers,
|
||||
},
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
event = "BufReadPre",
|
||||
dependencies = {
|
||||
{ "williamboman/mason.nvim" },
|
||||
{ "neovim/nvim-lspconfig" },
|
||||
},
|
||||
opts = {
|
||||
-- ensure_installed = require("config.servers").servers,
|
||||
-- automatic_installation = false,
|
||||
},
|
||||
},
|
||||
-- {
|
||||
-- "williamboman/mason-lspconfig.nvim",
|
||||
-- event = "BufReadPre",
|
||||
-- dependencies = {
|
||||
-- { "williamboman/mason.nvim" },
|
||||
-- { "neovim/nvim-lspconfig" },
|
||||
-- },
|
||||
-- opts = {
|
||||
-- -- ensure_installed = require("config.servers").servers,
|
||||
-- -- automatic_installation = false,
|
||||
-- },
|
||||
-- },
|
||||
{ import = "plugins.mod.conform-nvim" },
|
||||
{ "nvim-treesitter/nvim-treesitter-context", lazy = true },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,11 +38,3 @@ return {
|
|||
end
|
||||
end,
|
||||
|
||||
-- example calling setup directly for each LSP
|
||||
-- config = function()
|
||||
-- local capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||
-- local lspconfig = require('lspconfig')
|
||||
--
|
||||
-- lspconfig['lua_ls'].setup({ capabilities = capabilities })
|
||||
-- end
|
||||
}
|
||||
|
|
|
|||
4
tools/nvim/readme.md
Normal file
4
tools/nvim/readme.md
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
## Language Servers (v0.11)
|
||||
|
||||
[References](https://github.com/rockyzhang24/dotfiles/tree/master/.config/nvim/lsp)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue