Massive nvim refactor, migrated from nvim-lspconfig to NVIM 0.11 lsp/*
also migrated most LSP clients to nix rather than mason
This commit is contained in:
@@ -15,6 +15,12 @@ require('options')
|
||||
vim.schedule(function()
|
||||
require('keymaps')
|
||||
require('commands')
|
||||
|
||||
-- Enable all LSPs
|
||||
local lsp = require('lsp')
|
||||
for server, _ in pairs(lsp) do
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
end)
|
||||
|
||||
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"auto-save.nvim": { "branch": "main", "commit": "29f793a3a7f98129387590269ffe3ad61ab5e509" },
|
||||
"auto-session": { "branch": "main", "commit": "7a61d31770bffcf0e31a40781314699b6e66c7ab" },
|
||||
"aw-watcher.nvim": { "branch": "master", "commit": "be7b03748f59b6602502baf08e7f7736cc7279a5" },
|
||||
"blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" },
|
||||
"buffer-vacuum": { "branch": "main", "commit": "9ec0ea4ee93bb1faa0419d6890daf9e45c436ea6" },
|
||||
"buffer_manager.nvim": { "branch": "main", "commit": "9c8c6c9d0e877920e4814f74cb24537eeac305e3" },
|
||||
"ccc.nvim": { "branch": "main", "commit": "af2cf5a963f401aad868c065222ee13d4bbc9050" },
|
||||
@@ -66,7 +67,7 @@
|
||||
"rustaceanvim": { "branch": "master", "commit": "e9c5aaba16fead831379d5f44617547a90b913c7" },
|
||||
"snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" },
|
||||
"spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" },
|
||||
"tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "cd401038de4cbae37651cfe02510294ccf5cdc98" },
|
||||
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },
|
||||
|
||||
8
.config/nvim/lsp/asm_lsp.lua
Normal file
8
.config/nvim/lsp/asm_lsp.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
-- https://github.com/bergercookie/asm-lsp
|
||||
|
||||
return {
|
||||
mason = false,
|
||||
cmd = { 'asm-lsp' },
|
||||
filetypes = { 'asm', 'vmasm' },
|
||||
root_markers = { '.asm-lsp.toml', '.git' },
|
||||
}
|
||||
20
.config/nvim/lsp/astro.lua
Normal file
20
.config/nvim/lsp/astro.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
-- https://github.com/withastro/language-tools/tree/main/packages/language-server
|
||||
|
||||
local function get_typescript_server_path(root_dir)
|
||||
local project_root = vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1])
|
||||
return project_root and vim.fs.joinpath(project_root, 'node_modules', 'typescript', 'lib') or ''
|
||||
end
|
||||
|
||||
return {
|
||||
cmd = { 'astro-ls', '--stdio' },
|
||||
filetypes = { 'astro' },
|
||||
root_markers = { 'package.json', 'tsconfig.json', 'jsconfig.json', '.git' },
|
||||
init_options = {
|
||||
typescript = {},
|
||||
},
|
||||
before_init = function(_, config)
|
||||
if config.init_options and config.init_options.typescript and not config.init_options.typescript.tsdk then
|
||||
config.init_options.typescript.tsdk = get_typescript_server_path(config.root_dir)
|
||||
end
|
||||
end,
|
||||
}
|
||||
56
.config/nvim/lsp/basedpyright.lua
Normal file
56
.config/nvim/lsp/basedpyright.lua
Normal file
@@ -0,0 +1,56 @@
|
||||
-- https://detachhead.github.io/basedpyright
|
||||
|
||||
local function set_python_path(path)
|
||||
local clients = vim.lsp.get_clients({
|
||||
bufnr = vim.api.nvim_get_current_buf(),
|
||||
name = 'basedpyright',
|
||||
})
|
||||
for _, client in ipairs(clients) do
|
||||
if client.settings then
|
||||
client.settings.python = vim.tbl_deep_extend('force', client.settings.python or {}, { pythonPath = path })
|
||||
else
|
||||
client.config.settings =
|
||||
vim.tbl_deep_extend('force', client.config.settings, { python = { pythonPath = path } })
|
||||
end
|
||||
client.notify('workspace/didChangeConfiguration', { settings = nil })
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
cmd = { 'basedpyright-langserver', '--stdio' },
|
||||
filetypes = { 'python' },
|
||||
root_markers = {
|
||||
'pyproject.toml',
|
||||
'setup.py',
|
||||
'setup.cfg',
|
||||
'requirements.txt',
|
||||
'Pipfile',
|
||||
'pyrightconfig.json',
|
||||
'.git',
|
||||
},
|
||||
settings = {
|
||||
basedpyright = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
diagnosticMode = 'openFilesOnly',
|
||||
},
|
||||
},
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'LspPyrightOrganizeImports', function()
|
||||
client:exec_cmd({
|
||||
command = 'basedpyright.organizeimports',
|
||||
arguments = { vim.uri_from_bufnr(bufnr) },
|
||||
})
|
||||
end, {
|
||||
desc = 'Organize Imports',
|
||||
})
|
||||
|
||||
vim.api.nvim_buf_create_user_command(0, 'LspPyrightSetPythonPath', set_python_path, {
|
||||
desc = 'Reconfigure basedpyright with the provided python path',
|
||||
nargs = 1,
|
||||
complete = 'file',
|
||||
})
|
||||
end,
|
||||
}
|
||||
12
.config/nvim/lsp/bashls.lua
Normal file
12
.config/nvim/lsp/bashls.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- https://github.com/bash-lsp/bash-language-server
|
||||
|
||||
return {
|
||||
cmd = { 'bash-language-server', 'start' },
|
||||
filetypes = { 'bash', 'sh', 'zsh' },
|
||||
root_markers = { '.git' },
|
||||
settings = {
|
||||
bashIde = {
|
||||
globPattern = '*@(.sh|.inc|.bash|.command)',
|
||||
},
|
||||
},
|
||||
}
|
||||
107
.config/nvim/lsp/clangd.lua
Normal file
107
.config/nvim/lsp/clangd.lua
Normal file
@@ -0,0 +1,107 @@
|
||||
-- https://clangd.llvm.org/installation.html
|
||||
---
|
||||
--- - **NOTE:** Clang >= 11 is recommended! See [#23](https://github.com/neovim/nvim-lspconfig/issues/23).
|
||||
--- - If `compile_commands.json` lives in a build directory, you should
|
||||
--- symlink it to the root of your source tree.
|
||||
--- ```
|
||||
--- ln -s /path/to/myproject/build/compile_commands.json /path/to/myproject/
|
||||
--- ```
|
||||
--- - clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)
|
||||
--- specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson
|
||||
|
||||
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
|
||||
local function switch_source_header(bufnr)
|
||||
local method_name = 'textDocument/switchSourceHeader'
|
||||
local client = vim.lsp.get_clients({ bufnr = bufnr, name = 'clangd' })[1]
|
||||
if not client then
|
||||
return vim.notify(
|
||||
('method %s is not supported by any servers active on the current buffer'):format(method_name)
|
||||
)
|
||||
end
|
||||
local params = vim.lsp.util.make_text_document_params(bufnr)
|
||||
client.request(method_name, params, function(err, result)
|
||||
if err then
|
||||
error(tostring(err))
|
||||
end
|
||||
if not result then
|
||||
vim.notify('corresponding file cannot be determined')
|
||||
return
|
||||
end
|
||||
vim.cmd.edit(vim.uri_to_fname(result))
|
||||
end, bufnr)
|
||||
end
|
||||
|
||||
local function symbol_info()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local clangd_client = vim.lsp.get_clients({ bufnr = bufnr, name = 'clangd' })[1]
|
||||
if not clangd_client or not clangd_client.supports_method('textDocument/symbolInfo') then
|
||||
return vim.notify('Clangd client not found', vim.log.levels.ERROR)
|
||||
end
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local params = vim.lsp.util.make_position_params(win, clangd_client.offset_encoding)
|
||||
clangd_client.request('textDocument/symbolInfo', params, function(err, res)
|
||||
if err or #res == 0 then
|
||||
-- Clangd always returns an error, there is not reason to parse it
|
||||
return
|
||||
end
|
||||
local container = string.format('container: %s', res[1].containerName) ---@type string
|
||||
local name = string.format('name: %s', res[1].name) ---@type string
|
||||
vim.lsp.util.open_floating_preview({ name, container }, '', {
|
||||
height = 2,
|
||||
width = math.max(string.len(name), string.len(container)),
|
||||
focusable = false,
|
||||
focus = false,
|
||||
border = 'single',
|
||||
title = 'Symbol Info',
|
||||
})
|
||||
end, bufnr)
|
||||
end
|
||||
|
||||
return {
|
||||
mason = false,
|
||||
cmd = {
|
||||
'clangd',
|
||||
'--background-index',
|
||||
'--clang-tidy',
|
||||
'--header-insertion=iwyu',
|
||||
'--completion-style=detailed',
|
||||
'--function-arg-placeholders',
|
||||
'--fallback-style=llvm',
|
||||
},
|
||||
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda', 'proto' },
|
||||
root_markers = {
|
||||
'.clangd',
|
||||
'.clang-tidy',
|
||||
'.clang-format',
|
||||
'compile_commands.json',
|
||||
'compile_flags.txt',
|
||||
'configure.ac', -- AutoTools
|
||||
'.git',
|
||||
},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
completeUnimported = true,
|
||||
clangdFileStatus = true,
|
||||
},
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
editsNearCursor = true,
|
||||
},
|
||||
},
|
||||
offsetEncoding = { 'utf-8', 'utf-16' },
|
||||
},
|
||||
on_attach = function()
|
||||
vim.api.nvim_buf_create_user_command(0, 'ClangdSwitchSourceHeader', function()
|
||||
switch_source_header(0)
|
||||
end, { desc = 'Switch between source/header' })
|
||||
|
||||
vim.api.nvim_buf_create_user_command(0, 'ClangdShowSymbolInfo', function()
|
||||
symbol_info()
|
||||
end, { desc = 'Show symbol info' })
|
||||
|
||||
vim.keymap.set('n', 'H', '<cmd>ClangdSwitchSourceHeader<cr>', { desc = '[H]eader and Source Switcher' })
|
||||
vim.keymap.set('n', 'K', '<cmd>lua require("pretty_hover").hover()<cr>', { desc = 'Documentation Hover' })
|
||||
-- TODO: do I need pretty_hover? maybe that's what causes issues?
|
||||
end,
|
||||
}
|
||||
21
.config/nvim/lsp/cssls.lua
Normal file
21
.config/nvim/lsp/cssls.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
-- https://github.com/hrsh7th/vscode-langservers-extracted
|
||||
|
||||
return {
|
||||
cmd = { 'vscode-css-language-server', '--stdio' },
|
||||
filetypes = { 'css', 'scss', 'less', 'astro' },
|
||||
init_options = {
|
||||
provideFormatter = true,
|
||||
},
|
||||
root_markers = { 'package.json', '.git' },
|
||||
settings = {
|
||||
css = {
|
||||
validate = true,
|
||||
},
|
||||
less = {
|
||||
validate = true,
|
||||
},
|
||||
scss = {
|
||||
validate = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
91
.config/nvim/lsp/gopls.lua
Normal file
91
.config/nvim/lsp/gopls.lua
Normal file
@@ -0,0 +1,91 @@
|
||||
-- https://github.com/golang/tools/tree/master/gopls
|
||||
|
||||
local mod_cache = nil
|
||||
|
||||
---@param fname string
|
||||
---@return string?
|
||||
local function get_root(fname)
|
||||
if mod_cache and fname:sub(1, #mod_cache) == mod_cache then
|
||||
local clients = vim.lsp.get_clients({ name = 'gopls' })
|
||||
if #clients > 0 then
|
||||
return clients[#clients].config.root_dir
|
||||
end
|
||||
end
|
||||
return vim.fs.root(fname, { 'go.work', 'go.mod', '.git' })
|
||||
end
|
||||
|
||||
return {
|
||||
cmd = { 'gopls' },
|
||||
filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' },
|
||||
root_dir = function(bufnr, on_dir)
|
||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||
-- see: https://github.com/neovim/nvim-lspconfig/issues/804
|
||||
if mod_cache then
|
||||
on_dir(get_root(fname))
|
||||
return
|
||||
end
|
||||
local cmd = { 'go', 'env', 'GOMODCACHE' }
|
||||
vim.system(cmd, { text = true }, function(output)
|
||||
if output.code == 0 then
|
||||
if output.stdout then
|
||||
mod_cache = vim.trim(output.stdout)
|
||||
end
|
||||
on_dir(get_root(fname))
|
||||
else
|
||||
vim.notify(('[gopls] cmd failed with code %d: %s\n%s'):format(output.code, cmd, output.stderr))
|
||||
end
|
||||
end)
|
||||
end,
|
||||
settings = {
|
||||
gopls = {
|
||||
gofumpt = true,
|
||||
codelenses = {
|
||||
gc_details = false,
|
||||
generate = true,
|
||||
regenerate_cgo = true,
|
||||
run_govulncheck = true,
|
||||
test = true,
|
||||
tidy = true,
|
||||
upgrade_dependency = true,
|
||||
vendor = true,
|
||||
},
|
||||
hints = {
|
||||
assignVariableTypes = false,
|
||||
compositeLiteralFields = false,
|
||||
compositeLiteralTypes = true,
|
||||
constantValues = true,
|
||||
functionTypeParameters = false,
|
||||
parameterNames = false,
|
||||
rangeVariableTypes = true,
|
||||
},
|
||||
analyses = {
|
||||
fieldalignment = true,
|
||||
nilness = true,
|
||||
unusedparams = true,
|
||||
unusedwrite = true,
|
||||
useany = true,
|
||||
},
|
||||
usePlaceholders = false,
|
||||
completeUnimported = true,
|
||||
staticcheck = true,
|
||||
directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' },
|
||||
semanticTokens = true,
|
||||
},
|
||||
},
|
||||
on_attach = function(client, _)
|
||||
-- workaround for gopls not supporting semanticTokensProvider
|
||||
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242
|
||||
if not client.server_capabilities.semanticTokensProvider then
|
||||
local semantic = client.config.capabilities.textDocument.semanticTokens
|
||||
client.server_capabilities.semanticTokensProvider = {
|
||||
full = true,
|
||||
legend = {
|
||||
tokenTypes = semantic.tokenTypes,
|
||||
tokenModifiers = semantic.tokenModifiers,
|
||||
},
|
||||
range = true,
|
||||
}
|
||||
end
|
||||
-- end workaround
|
||||
end,
|
||||
}
|
||||
16
.config/nvim/lsp/html.lua
Normal file
16
.config/nvim/lsp/html.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- https://github.com/hrsh7th/vscode-langservers-extracted
|
||||
|
||||
return {
|
||||
cmd = { 'vscode-html-language-server', '--stdio' },
|
||||
filetypes = { 'html', 'templ' },
|
||||
init_options = {
|
||||
configurationSection = { 'html', 'css', 'javascript' },
|
||||
embeddedLanguages = {
|
||||
css = true,
|
||||
javascript = true,
|
||||
},
|
||||
provideFormatter = true,
|
||||
},
|
||||
root_markers = { 'package.json', '.git' },
|
||||
settings = {},
|
||||
}
|
||||
10
.config/nvim/lsp/jsonls.lua
Normal file
10
.config/nvim/lsp/jsonls.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
-- https://github.com/hrsh7th/vscode-langservers-extracted
|
||||
|
||||
return {
|
||||
cmd = { 'vscode-json-language-server', '--stdio' },
|
||||
filetypes = { 'json', 'jsonc' },
|
||||
init_options = {
|
||||
provideformatter = true,
|
||||
},
|
||||
root_markers = { '.git' },
|
||||
}
|
||||
7
.config/nvim/lsp/lemminx.lua
Normal file
7
.config/nvim/lsp/lemminx.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- https://github.com/eclipse/lemminx
|
||||
|
||||
return {
|
||||
cmd = { 'lemminx' },
|
||||
filetypes = { 'xml', 'xsd', 'xsl', 'xslt', 'svg' },
|
||||
root_markers = { '.git' },
|
||||
}
|
||||
47
.config/nvim/lsp/lua_ls.lua
Normal file
47
.config/nvim/lsp/lua_ls.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
-- https://github.com/luals/lua-language-server
|
||||
|
||||
return {
|
||||
on_init = function(client)
|
||||
if client.workspace_folders then
|
||||
local path = client.workspace_folders[1].name
|
||||
if
|
||||
path ~= vim.fn.stdpath('config')
|
||||
and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc'))
|
||||
then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using
|
||||
-- (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
},
|
||||
-- Make the server aware of Neovim runtime files
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME,
|
||||
-- Depending on the usage, you might want to add additional paths here.
|
||||
-- "${3rd}/luv/library"
|
||||
-- "${3rd}/busted/library",
|
||||
},
|
||||
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
|
||||
-- library = vim.api.nvim_get_runtime_file("", true)
|
||||
},
|
||||
})
|
||||
end,
|
||||
settings = {
|
||||
Lua = {},
|
||||
diagnostics = { globals = { 'vim' } },
|
||||
telemetry = { enabled = false },
|
||||
hint = { enable = true },
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
|
||||
[vim.fn.stdpath('config') .. '/lua'] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
14
.config/nvim/lsp/markdown_oxide.lua
Normal file
14
.config/nvim/lsp/markdown_oxide.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- https://github.com/Feel-ix-343/markdown-oxide
|
||||
|
||||
return {
|
||||
root_markers = { '.git', '.obsidian', '.moxide.toml' },
|
||||
filetypes = { 'markdown' },
|
||||
cmd = { 'markdown-oxide' },
|
||||
capabilities = {
|
||||
workspace = {
|
||||
didChangeWatchedFiles = {
|
||||
dynamicRegistration = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
7
.config/nvim/lsp/marksman.lua
Normal file
7
.config/nvim/lsp/marksman.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- https://github.com/artempyanykh/marksman
|
||||
|
||||
return {
|
||||
cmd = { 'marksman', 'server' },
|
||||
filetypes = { 'markdown', 'markdown.mdx' },
|
||||
root_markers = { '.marksman.toml', '.git' },
|
||||
}
|
||||
21
.config/nvim/lsp/mdx_analyzer.lua
Normal file
21
.config/nvim/lsp/mdx_analyzer.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
-- https://github.com/mdx-js/mdx-analyzer
|
||||
|
||||
local function get_typescript_server_path(root_dir)
|
||||
local project_root = vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1])
|
||||
return project_root and vim.fs.joinpath(project_root, 'node_modules', 'typescript', 'lib') or ''
|
||||
end
|
||||
|
||||
return {
|
||||
cmd = { 'mdx-language-server', '--stdio' },
|
||||
filetypes = { 'mdx' },
|
||||
root_markers = { 'package.json' },
|
||||
settings = {},
|
||||
init_options = {
|
||||
typescript = {},
|
||||
},
|
||||
before_init = function(_, config)
|
||||
if config.init_options and config.init_options.typescript and not config.init_options.typescript.tsdk then
|
||||
config.init_options.typescript.tsdk = get_typescript_server_path(config.root_dir)
|
||||
end
|
||||
end,
|
||||
}
|
||||
7
.config/nvim/lsp/neocmake.lua
Normal file
7
.config/nvim/lsp/neocmake.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- https://github.com/Decodetalkers/neocmakelsp
|
||||
|
||||
return {
|
||||
cmd = { 'neocmakelsp', '--stdio' },
|
||||
filetypes = { 'cmake' },
|
||||
root_markers = { '.git', 'build', 'cmake' },
|
||||
}
|
||||
7
.config/nvim/lsp/nil_ls.lua
Normal file
7
.config/nvim/lsp/nil_ls.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- https://github.com/oxalica/nil
|
||||
|
||||
return {
|
||||
cmd = { 'nil' },
|
||||
filetypes = { 'nix' },
|
||||
root_markers = { 'flake.nix', '.git' },
|
||||
}
|
||||
133
.config/nvim/lsp/tailwindcss.lua
Normal file
133
.config/nvim/lsp/tailwindcss.lua
Normal file
@@ -0,0 +1,133 @@
|
||||
-- https://github.com/tailwindlabs/tailwindcss-intellisense
|
||||
|
||||
local function insert_package_json(config_files, field, fname)
|
||||
local path = vim.fn.fnamemodify(fname, ':h')
|
||||
local root_with_package = vim.fs.dirname(vim.fs.find('package.json', { path = path, upward = true })[1])
|
||||
|
||||
if root_with_package then
|
||||
-- only add package.json if it contains field parameter
|
||||
local path_sep = '/'
|
||||
for line in io.lines(root_with_package .. path_sep .. 'package.json') do
|
||||
if line:find(field) then
|
||||
config_files[#config_files + 1] = 'package.json'
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return config_files
|
||||
end
|
||||
|
||||
return {
|
||||
cmd = { 'tailwindcss-language-server', '--stdio' },
|
||||
-- filetypes copied and adjusted from tailwindcss-intellisense
|
||||
filetypes = {
|
||||
-- html
|
||||
'aspnetcorerazor',
|
||||
'astro',
|
||||
'astro-markdown',
|
||||
'blade',
|
||||
'clojure',
|
||||
'django-html',
|
||||
'htmldjango',
|
||||
'edge',
|
||||
'eelixir', -- vim ft
|
||||
'elixir',
|
||||
'ejs',
|
||||
'erb',
|
||||
'eruby', -- vim ft
|
||||
'gohtml',
|
||||
'gohtmltmpl',
|
||||
'haml',
|
||||
'handlebars',
|
||||
'hbs',
|
||||
'html',
|
||||
'htmlangular',
|
||||
'html-eex',
|
||||
'heex',
|
||||
'jade',
|
||||
'leaf',
|
||||
'liquid',
|
||||
'markdown',
|
||||
'mdx',
|
||||
'mustache',
|
||||
'njk',
|
||||
'nunjucks',
|
||||
'php',
|
||||
'razor',
|
||||
'slim',
|
||||
'twig',
|
||||
-- css
|
||||
'css',
|
||||
'less',
|
||||
'postcss',
|
||||
'sass',
|
||||
'scss',
|
||||
'stylus',
|
||||
'sugarss',
|
||||
-- js
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'reason',
|
||||
'rescript',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
-- mixed
|
||||
'vue',
|
||||
'svelte',
|
||||
'templ',
|
||||
},
|
||||
settings = {
|
||||
tailwindCSS = {
|
||||
validate = true,
|
||||
lint = {
|
||||
cssConflict = 'warning',
|
||||
invalidApply = 'error',
|
||||
invalidScreen = 'error',
|
||||
invalidVariant = 'error',
|
||||
invalidConfigPath = 'error',
|
||||
invalidTailwindDirective = 'error',
|
||||
recommendedVariantOrder = 'warning',
|
||||
},
|
||||
classAttributes = {
|
||||
'class',
|
||||
'className',
|
||||
'class:list',
|
||||
'classList',
|
||||
'ngClass',
|
||||
},
|
||||
includeLanguages = {
|
||||
eelixir = 'html-eex',
|
||||
eruby = 'erb',
|
||||
templ = 'html',
|
||||
htmlangular = 'html',
|
||||
},
|
||||
},
|
||||
},
|
||||
before_init = function(_, config)
|
||||
if not config.settings then
|
||||
config.settings = {}
|
||||
end
|
||||
if not config.settings.editor then
|
||||
config.settings.editor = {}
|
||||
end
|
||||
if not config.settings.editor.tabSize then
|
||||
config.settings.editor.tabSize = vim.lsp.util.get_effective_tabstop()
|
||||
end
|
||||
end,
|
||||
workspace_required = true,
|
||||
root_dir = function(bufnr, on_dir)
|
||||
local root_files = {
|
||||
'tailwind.config.js',
|
||||
'tailwind.config.cjs',
|
||||
'tailwind.config.mjs',
|
||||
'tailwind.config.ts',
|
||||
'postcss.config.js',
|
||||
'postcss.config.cjs',
|
||||
'postcss.config.mjs',
|
||||
'postcss.config.ts',
|
||||
}
|
||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||
root_files = insert_package_json(root_files, 'tailwindcss', fname)
|
||||
on_dir(vim.fs.dirname(vim.fs.find(root_files, { path = fname, upward = true })[1]))
|
||||
end,
|
||||
}
|
||||
7
.config/nvim/lsp/taplo.lua
Normal file
7
.config/nvim/lsp/taplo.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- https://taplo.tamasfe.dev/cli/usage/language-server.html
|
||||
|
||||
return {
|
||||
cmd = { 'taplo', 'lsp', 'stdio' },
|
||||
filetypes = { 'toml' },
|
||||
root_markers = { '.git' },
|
||||
}
|
||||
47
.config/nvim/lsp/ts_ls.lua
Normal file
47
.config/nvim/lsp/ts_ls.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
-- https://github.com/typescript-language-server/typescript-language-server
|
||||
|
||||
--- Use the `:LspTypescriptSourceAction` command to see "whole file" ("source") code-actions such as:
|
||||
--- - organize imports
|
||||
--- - remove unused code
|
||||
|
||||
return {
|
||||
init_options = { hostInfo = 'neovim' },
|
||||
cmd = { 'typescript-language-server', '--stdio' },
|
||||
filetypes = {
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'javascript.jsx',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
'typescript.tsx',
|
||||
},
|
||||
root_markers = { 'tsconfig.json', 'jsconfig.json', 'package.json', '.git' },
|
||||
handlers = {
|
||||
-- handle rename request for certain code actions like extracting functions / types
|
||||
['_typescript.rename'] = function(_, result, ctx)
|
||||
local client = assert(vim.lsp.get_client_by_id(ctx.client_id))
|
||||
vim.lsp.util.show_document({
|
||||
uri = result.textDocument.uri,
|
||||
range = {
|
||||
start = result.position,
|
||||
['end'] = result.position,
|
||||
},
|
||||
}, client.offset_encoding)
|
||||
vim.lsp.buf.rename()
|
||||
return vim.NIL
|
||||
end,
|
||||
},
|
||||
on_attach = function(client)
|
||||
-- ts_ls provides `source.*` code actions that apply to the whole file. These only appear in
|
||||
-- `vim.lsp.buf.code_action()` if specified in `context.only`.
|
||||
vim.api.nvim_buf_create_user_command(0, 'LspTypescriptSourceAction', function()
|
||||
local source_actions = vim.tbl_filter(function(action)
|
||||
return vim.startswith(action, 'source.')
|
||||
end, client.server_capabilities.codeActionProvider.codeActionKinds)
|
||||
|
||||
vim.lsp.buf.code_action({
|
||||
context = { only = source_actions },
|
||||
})
|
||||
end, {})
|
||||
end,
|
||||
}
|
||||
14
.config/nvim/lsp/yamlls.lua
Normal file
14
.config/nvim/lsp/yamlls.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- https://github.com/redhat-developer/yaml-language-server
|
||||
|
||||
return {
|
||||
cmd = { 'yaml-language-server', '--stdio' },
|
||||
filetypes = { 'yaml', 'yaml.docker-compose', 'yaml.gitlab' },
|
||||
root_markers = { '.git' },
|
||||
settings = {
|
||||
redhat = {
|
||||
telemetry = {
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
24
.config/nvim/lsp/zls.lua
Normal file
24
.config/nvim/lsp/zls.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
-- https://github.com/zigtools/zls
|
||||
|
||||
return {
|
||||
mason = false,
|
||||
cmd = { 'zls' },
|
||||
filetypes = { 'zig', 'zir' },
|
||||
root_markers = { 'zls.json', 'build.zig', '.git' },
|
||||
workspace_required = false,
|
||||
settings = {
|
||||
zls = {
|
||||
enable_build_on_save = true,
|
||||
build_on_save_args = {},
|
||||
enable_argument_placeholders = false,
|
||||
warn_style = true,
|
||||
|
||||
inlay_hints_show_variable_type_hints = true,
|
||||
inlay_hints_show_struct_literal_field_type = true,
|
||||
inlay_hints_show_parameter_name = true,
|
||||
inlay_hints_show_builtin = true,
|
||||
inlay_hints_hide_redundant_param_names = true,
|
||||
inlay_hints_hide_redundant_param_names_last_token = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -15,6 +15,7 @@ end
|
||||
local function yank_filepath_to_clipboard(os)
|
||||
return function()
|
||||
local filepath = vim.fn.expand('%:p')
|
||||
-- TODO: simplify bcz idc about windows anymore
|
||||
if os == 'linux' then
|
||||
local home_dir = vim.fn.expand('~')
|
||||
filepath = filepath:gsub(home_dir, '~')
|
||||
@@ -58,8 +59,8 @@ set({ 'n', 'x' }, 'p', '<cmd>lua RemoveClipboardCR()<cr>p', { noremap = true })
|
||||
set({ 'n', 'x' }, 'P', '<cmd>lua RemoveClipboardCR()<cr>P', { noremap = true })
|
||||
|
||||
-- Move lines around
|
||||
set('n', '<A-j>', ":m .+1<cr>", { noremap = true })
|
||||
set('n', '<A-k>', ":m .-2<cr>", { noremap = true })
|
||||
set('n', '<A-j>', ':m .+1<cr>', { noremap = true })
|
||||
set('n', '<A-k>', ':m .-2<cr>', { noremap = true })
|
||||
set('v', '<A-j>', ":m '>+1<cr>gv", { noremap = true })
|
||||
set('v', '<A-k>', ":m '<-2<cr>gv", { noremap = true })
|
||||
|
||||
@@ -99,3 +100,73 @@ set('n', '<leader><leader>x', '<cmd>source %<CR>', { desc = 'Execute the current
|
||||
|
||||
-- Reformats file using lsp
|
||||
set('n', '=', vim.lsp.buf.format, { desc = 'Format File' })
|
||||
|
||||
-- LSP keymaps
|
||||
local severity = vim.diagnostic.severity
|
||||
local function next_diagnostic(diagnostic_severity)
|
||||
return function()
|
||||
require('lspsaga.diagnostic'):goto_next({ severity = diagnostic_severity })
|
||||
end
|
||||
end
|
||||
local function prev_diagnostic(diagnostic_severity)
|
||||
return function()
|
||||
require('lspsaga.diagnostic'):goto_prev({ severity = diagnostic_severity })
|
||||
end
|
||||
end
|
||||
local function cursor_diagnostics()
|
||||
vim.diagnostic.open_float({
|
||||
scope = 'cursor',
|
||||
border = 'single',
|
||||
})
|
||||
end
|
||||
|
||||
local keymaps = {
|
||||
{ 'n', 'gd', '<cmd>Lspsaga goto_definition<cr>', { desc = '[G]oto [D]efinition' } },
|
||||
{ 'n', 'gu', '<cmd>Lspsaga finder<cr>', { desc = '[G]oto [U]sages' } },
|
||||
{ { 'n', 'i' }, '<C-p>', vim.lsp.buf.signature_help, { desc = 'Show [P]arameters' } },
|
||||
{ 'n', 'K', '<cmd>Lspsaga hover_doc<cr>', { desc = 'Documentation' } },
|
||||
{ 'n', 'R', '<cmd>Lspsaga rename<cr>', { desc = '[R]ename' } },
|
||||
{ { 'n', 'i' }, '<M-Enter>', '<cmd>Lspsaga code_action<cr>', { desc = 'Code Actions' } },
|
||||
{ 'n', '<leader>ca', '<cmd>Lspsaga code_action<cr><Esc>', { desc = '[C]ode [A]ctions' } },
|
||||
{ 'n', '<leader>e', next_diagnostic(severity.ERROR), { desc = 'Goto [E]rror' } },
|
||||
{ 'n', '<leader>E', prev_diagnostic(severity.ERROR), { desc = 'Goto [E]rror (prev)' } },
|
||||
{ 'n', '<leader>w', next_diagnostic(severity.WARN), { desc = 'Goto [W]arning' } },
|
||||
{ 'n', '<leader>W', prev_diagnostic(severity.WARN), { desc = 'Goto [W]arning (prev)' } },
|
||||
{ 'n', '<leader>D', cursor_diagnostics, { desc = '[D]iagnostics under cursor' } },
|
||||
}
|
||||
|
||||
for _, ft in ipairs({ 'c', 'h', 'cpp', 'hpp' }) do
|
||||
keymaps[ft] = {
|
||||
{ 'n', 'H', '<cmd>ClangdSwitchSourceHeader<cr>', { desc = '[H]eader and Source Switcher' } },
|
||||
{ 'n', 'K', '<cmd>lua require("pretty_hover").hover()<cr>', { desc = 'Documentation Hover' } },
|
||||
}
|
||||
end
|
||||
|
||||
local function set_keymaps(tbl, bufnr)
|
||||
for _, keymap in ipairs(tbl) do
|
||||
local mode = keymap[1]
|
||||
local lhs = keymap[2]
|
||||
local rhs = keymap[3]
|
||||
local opts = keymap[4] or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
desc = 'Register LSP keymaps',
|
||||
group = vim.api.nvim_create_augroup('lsp-keymaps', { clear = true }),
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
|
||||
local filetype = vim.bo[bufnr].filetype
|
||||
set_keymaps(keymaps, bufnr)
|
||||
for ft, tbl in pairs(keymaps) do
|
||||
if type(ft) == 'number' or ft ~= filetype then
|
||||
goto continue
|
||||
end
|
||||
set_keymaps(tbl, bufnr)
|
||||
::continue::
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
-- NOTE: a table or true to enable, false to disable
|
||||
return {
|
||||
lua_ls = {
|
||||
settings = {
|
||||
diagnostics = { globals = { 'vim' } },
|
||||
telemetry = { enabled = false },
|
||||
hint = { enable = true },
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
|
||||
[vim.fn.stdpath('config') .. '/lua'] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}, -- lua
|
||||
clangd = {
|
||||
mason = false,
|
||||
cmd = {
|
||||
'clangd',
|
||||
'--background-index',
|
||||
'--clang-tidy',
|
||||
'--header-insertion=iwyu',
|
||||
'--completion-style=detailed',
|
||||
'--function-arg-placeholders',
|
||||
'--fallback-style=llvm',
|
||||
},
|
||||
root_dir = function(filename)
|
||||
return require('lspconfig/util').root_pattern(
|
||||
'.clang-tidy',
|
||||
'.clang-format',
|
||||
'compile_commands.json',
|
||||
'.git'
|
||||
)(filename) or vim.fn.getcwd()
|
||||
end,
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
completeUnimported = true,
|
||||
clangdFileStatus = true,
|
||||
},
|
||||
}, -- c/cpp
|
||||
neocmake = {
|
||||
root_dir = function(filename)
|
||||
return require('lspconfig/util').root_pattern(
|
||||
'CMakePresets.json',
|
||||
'CTestConfig.cmake',
|
||||
'build',
|
||||
'cmake',
|
||||
'.git' -- NOTE: git is last due to monorepos (so it tries to use build/cmake first)
|
||||
)(filename) or vim.fn.getcwd()
|
||||
end,
|
||||
},
|
||||
pyright = {
|
||||
settings = {
|
||||
python = {
|
||||
pythonPath = '~/python/venv/bin/python',
|
||||
},
|
||||
},
|
||||
}, -- python
|
||||
bashls = true, -- bash
|
||||
taplo = true, -- toml
|
||||
lemminx = true, -- xml
|
||||
yamlls = true, -- yaml
|
||||
jsonls = true, -- json
|
||||
html = true, -- html
|
||||
cssls = true, -- css
|
||||
ts_ls = true, -- javascript/typescript
|
||||
astro = true, -- astro framework
|
||||
mdx_analyzer = true, -- markdown with JS I think
|
||||
-- marksman = true, -- Markdown LSP
|
||||
markdown_oxide = true, -- Markdown LSP but better
|
||||
gopls = {
|
||||
cmd = { 'gopls' },
|
||||
filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' },
|
||||
root_dir = function(filename)
|
||||
return require('lspconfig/util').root_pattern('go.work', 'go.mod', '.git')(filename)
|
||||
end,
|
||||
settings = {
|
||||
gopls = {
|
||||
gofumpt = true,
|
||||
codelenses = {
|
||||
gc_details = false,
|
||||
generate = true,
|
||||
regenerate_cgo = true,
|
||||
run_govulncheck = true,
|
||||
test = true,
|
||||
tidy = true,
|
||||
upgrade_dependency = true,
|
||||
vendor = true,
|
||||
},
|
||||
hints = {
|
||||
assignVariableTypes = false,
|
||||
compositeLiteralFields = false,
|
||||
compositeLiteralTypes = true,
|
||||
constantValues = true,
|
||||
functionTypeParameters = false,
|
||||
parameterNames = false,
|
||||
rangeVariableTypes = true,
|
||||
},
|
||||
analyses = {
|
||||
fieldalignment = true,
|
||||
nilness = true,
|
||||
unusedparams = true,
|
||||
unusedwrite = true,
|
||||
useany = true,
|
||||
},
|
||||
usePlaceholders = false,
|
||||
completeUnimported = true,
|
||||
staticcheck = true,
|
||||
directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' },
|
||||
semanticTokens = true,
|
||||
},
|
||||
},
|
||||
}, -- Go LSP
|
||||
jdtls = true, -- java
|
||||
-- sqlls = true,
|
||||
-- sqls = {
|
||||
-- on_attach = function(client, bufnr)
|
||||
-- require('sqls').on_attach(client, bufnr)
|
||||
-- end,
|
||||
-- settings = {
|
||||
-- sqls = {
|
||||
-- connections = {
|
||||
-- {
|
||||
-- driver = 'sqlite3',
|
||||
-- dataSourceName = '/home/kyren/projects/eko/server.db',
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
zls = {
|
||||
mason = false,
|
||||
cmd = { 'zls' },
|
||||
settings = {
|
||||
zls = {
|
||||
enable_build_on_save = true,
|
||||
build_on_save_args = {},
|
||||
enable_argument_placeholders = false,
|
||||
warn_style = true,
|
||||
|
||||
inlay_hints_show_variable_type_hints = true,
|
||||
inlay_hints_show_struct_literal_field_type = true,
|
||||
inlay_hints_show_parameter_name = true,
|
||||
inlay_hints_show_builtin = true,
|
||||
inlay_hints_hide_redundant_param_names = true,
|
||||
inlay_hints_hide_redundant_param_names_last_token = true,
|
||||
},
|
||||
},
|
||||
}, -- zig
|
||||
nil_ls = {}, -- nix
|
||||
asm_lsp = {
|
||||
mason = false,
|
||||
cmd = { 'asm-lsp' },
|
||||
},
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
local severity = vim.diagnostic.severity
|
||||
local function next_diagnostic(diagnostic_severity)
|
||||
return function()
|
||||
require('lspsaga.diagnostic'):goto_next({ severity = diagnostic_severity })
|
||||
end
|
||||
end
|
||||
local function prev_diagnostic(diagnostic_severity)
|
||||
return function()
|
||||
require('lspsaga.diagnostic'):goto_prev({ severity = diagnostic_severity })
|
||||
end
|
||||
end
|
||||
local function cursor_diagnostics()
|
||||
vim.diagnostic.open_float({
|
||||
scope = 'cursor',
|
||||
border = 'single',
|
||||
})
|
||||
end
|
||||
|
||||
local keymaps = {
|
||||
{ 'n', 'gd', '<cmd>Lspsaga goto_definition<cr>', { desc = '[G]oto [D]efinition' } },
|
||||
{ 'n', 'gu', '<cmd>Lspsaga finder<cr>', { desc = '[G]oto [U]sages' } },
|
||||
{ { 'n', 'i' }, '<C-p>', vim.lsp.buf.signature_help, { desc = 'Show [P]arameters' } },
|
||||
{ 'n', 'K', '<cmd>Lspsaga hover_doc<cr>', { desc = 'Documentation' } },
|
||||
{ 'n', 'R', '<cmd>Lspsaga rename<cr>', { desc = '[R]ename' } },
|
||||
{ { 'n', 'i' }, '<M-Enter>', '<cmd>Lspsaga code_action<cr>', { desc = 'Code Actions' } },
|
||||
{ 'n', '<leader>ca', '<cmd>Lspsaga code_action<cr><Esc>', { desc = '[C]ode [A]ctions' } },
|
||||
{ 'n', '<leader>e', next_diagnostic(severity.ERROR), { desc = 'Goto [E]rror' } },
|
||||
{ 'n', '<leader>E', prev_diagnostic(severity.ERROR), { desc = 'Goto [E]rror (prev)' } },
|
||||
{ 'n', '<leader>w', next_diagnostic(severity.WARN), { desc = 'Goto [W]arning' } },
|
||||
{ 'n', '<leader>W', prev_diagnostic(severity.WARN), { desc = 'Goto [W]arning (prev)' } },
|
||||
{ 'n', '<leader>D', cursor_diagnostics, { desc = '[D]iagnostics under cursor' } },
|
||||
}
|
||||
|
||||
for _, ft in ipairs({ 'c', 'h', 'cpp', 'hpp' }) do
|
||||
keymaps[ft] = {
|
||||
{ 'n', 'H', '<cmd>ClangdSwitchSourceHeader<cr>', { desc = '[H]eader and Source Switcher' } },
|
||||
{ 'n', 'K', '<cmd>lua require("pretty_hover").hover()<cr>', { desc = 'Documentation Hover' } },
|
||||
}
|
||||
end
|
||||
|
||||
local function set_keymaps(tbl, bufnr)
|
||||
for _, keymap in ipairs(tbl) do
|
||||
local mode = keymap[1]
|
||||
local lhs = keymap[2]
|
||||
local rhs = keymap[3]
|
||||
local opts = keymap[4] or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Registers LSP keymaps for the given buffer
|
||||
---@param bufnr number: the id of the buffer
|
||||
M.setup = function(bufnr)
|
||||
local filetype = vim.bo[bufnr].filetype
|
||||
set_keymaps(keymaps, bufnr)
|
||||
for ft, tbl in pairs(keymaps) do
|
||||
if type(ft) == 'number' or ft ~= filetype then
|
||||
goto continue
|
||||
end
|
||||
set_keymaps(tbl, bufnr)
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,73 +1,23 @@
|
||||
local lspconfig = require('lspconfig')
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
local servers = require('language-servers')
|
||||
for name, config in pairs(servers) do
|
||||
if config == false then
|
||||
goto continue
|
||||
end
|
||||
if config == true then
|
||||
---@diagnostic disable-next-line: cast-local-type
|
||||
config = {}
|
||||
end
|
||||
|
||||
-- NOTE: there must be a better way to do it, but it will do for now
|
||||
if name == 'markdown_oxide' then
|
||||
---@diagnostic disable-next-line: cast-local-type
|
||||
config = vim.tbl_deep_extend('force', {}, {
|
||||
capabilities = vim.tbl_deep_extend('force', capabilities, {
|
||||
workspace = {
|
||||
didChangeWatchedFiles = {
|
||||
dynamicRegistration = true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
}, config)
|
||||
else
|
||||
---@diagnostic disable-next-line: cast-local-type
|
||||
config = vim.tbl_deep_extend('force', {}, {
|
||||
capabilities = capabilities,
|
||||
}, config)
|
||||
end
|
||||
|
||||
lspconfig[name].setup(config)
|
||||
::continue::
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local client = assert(vim.lsp.get_client_by_id(args.data.client_id), 'must have valid client')
|
||||
|
||||
local settings = servers[client.name]
|
||||
if type(settings) ~= 'table' then
|
||||
---@diagnostic disable-next-line: cast-local-type
|
||||
settings = {}
|
||||
end
|
||||
|
||||
-- Override server capabilities
|
||||
if settings.server_capabilities then
|
||||
for k, v in pairs(settings.server_capabilities) do
|
||||
if v == vim.NIL then
|
||||
v = nil
|
||||
end
|
||||
client.server_capabilities[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
-- Workaround for semantic tokens apparently?
|
||||
-- https://www.lazyvim.org/extras/lang/go
|
||||
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242
|
||||
if client.name == 'gopls' and not client.server_capabilities.semanticTokensProvider then
|
||||
local semantic = client.config.capabilities.textDocument.semanticTokens
|
||||
client.server_capabilities.semanticTokensProvider = {
|
||||
full = true,
|
||||
legend = { tokenModifiers = semantic.tokenModifiers, tokenTypes = semantic.tokenTypes },
|
||||
range = true,
|
||||
}
|
||||
end
|
||||
|
||||
-- Register buffer local LSP keymaps
|
||||
require('lsp-keymaps').setup(bufnr)
|
||||
end,
|
||||
})
|
||||
return {
|
||||
asm_lsp = true,
|
||||
astro = true,
|
||||
basedpyright = true, -- python
|
||||
bashls = true,
|
||||
clangd = true,
|
||||
cssls = true,
|
||||
gopls = true,
|
||||
html = true,
|
||||
jsonls = true,
|
||||
lemminx = true, -- xml
|
||||
lua_ls = true,
|
||||
markdown_oxide = true,
|
||||
marksman = false, -- markdown
|
||||
mdx_analyzer = true,
|
||||
neocmake = true,
|
||||
nil_ls = true, -- nix
|
||||
tailwindcss = true,
|
||||
taplo = true, -- toml
|
||||
ts_ls = true, -- typescript and yavashit
|
||||
yamlls = true,
|
||||
zls = true, -- zig
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ return {
|
||||
return {
|
||||
-- execution_message = { enabled = false }, removed
|
||||
condition = function(buf)
|
||||
-- TODO: oil issues might be bcz of autosaving?
|
||||
-- Maybe I should exclude Oil ft?
|
||||
-- Might be unrelated tho
|
||||
-- Oil error is "cannot save, action already in progress"
|
||||
|
||||
-- Save only if the buffer is not a "special buffer"
|
||||
return vim.fn.getbufvar(buf, '&buftype') == ''
|
||||
end,
|
||||
|
||||
44
.config/nvim/lua/plugins/blink-cmp.lua
Normal file
44
.config/nvim/lua/plugins/blink-cmp.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
return {
|
||||
'saghen/blink.cmp',
|
||||
version = '1.*',
|
||||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
opts = {
|
||||
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
|
||||
-- 'super-tab' for mappings similar to vscode (tab to accept)
|
||||
-- 'enter' for enter to accept
|
||||
-- 'none' for no mappings
|
||||
--
|
||||
-- All presets have the following mappings:
|
||||
-- C-space: Open menu or open docs if already open
|
||||
-- C-n/C-p or Up/Down: Select next/previous item
|
||||
-- C-e: Hide menu
|
||||
-- C-k: Toggle signature help (if signature.enabled = true)
|
||||
--
|
||||
-- See :h blink-cmp-config-keymap for defining your own keymap
|
||||
keymap = { preset = 'default' },
|
||||
|
||||
appearance = {
|
||||
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||
-- Adjusts spacing to ensure icons are aligned
|
||||
nerd_font_variant = 'mono',
|
||||
},
|
||||
|
||||
-- (Default) Only show the documentation popup when manually triggered
|
||||
completion = { documentation = { auto_show = false } },
|
||||
|
||||
-- Default list of enabled providers defined so that you can extend it
|
||||
-- elsewhere in your config, without redefining it, due to `opts_extend`
|
||||
sources = {
|
||||
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||
},
|
||||
|
||||
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||
--
|
||||
-- See the fuzzy documentation for more information
|
||||
fuzzy = { implementation = 'prefer_rust_with_warning' },
|
||||
},
|
||||
opts_extend = { 'sources.default' },
|
||||
}
|
||||
@@ -12,7 +12,7 @@ return {
|
||||
-- override the lsp markdown formatter with Noice
|
||||
['vim.lsp.util.stylize_markdown'] = true,
|
||||
-- override cmp documentation with Noice (needs the other options to work)
|
||||
['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp
|
||||
-- ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp
|
||||
},
|
||||
hover = {
|
||||
enabled = true,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
return {
|
||||
'hrsh7th/nvim-cmp',
|
||||
event = 'InsertEnter',
|
||||
dependencies = {
|
||||
'onsails/lspkind.nvim', -- icons for completion type
|
||||
'hrsh7th/cmp-path', -- complete filepaths
|
||||
'hrsh7th/cmp-nvim-lsp', -- lsp source for nvim-cmp
|
||||
'saadparwaiz1/cmp_luasnip', -- snippets source for nvim-cmp
|
||||
{ 'L3MON4D3/LuaSnip', build = 'make install_jsregexp' }, -- snippets plugin
|
||||
},
|
||||
config = function()
|
||||
require('cmp_helper')
|
||||
end,
|
||||
-- 'hrsh7th/nvim-cmp',
|
||||
-- event = 'InsertEnter',
|
||||
-- dependencies = {
|
||||
-- 'onsails/lspkind.nvim', -- icons for completion type
|
||||
-- 'hrsh7th/cmp-path', -- complete filepaths
|
||||
-- 'hrsh7th/cmp-nvim-lsp', -- lsp source for nvim-cmp
|
||||
-- 'saadparwaiz1/cmp_luasnip', -- snippets source for nvim-cmp
|
||||
-- { 'L3MON4D3/LuaSnip', build = 'make install_jsregexp' }, -- snippets plugin
|
||||
-- },
|
||||
-- config = function()
|
||||
-- require('cmp_helper')
|
||||
-- end,
|
||||
}
|
||||
|
||||
@@ -4,29 +4,9 @@ return {
|
||||
'neovim/nvim-lspconfig',
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
dependencies = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
-- 'hrsh7th/cmp-nvim-lsp',
|
||||
{ 'antosha417/nvim-lsp-file-operations', conifg = true },
|
||||
{
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
build = ':MasonUpdate',
|
||||
config = function()
|
||||
local language_servers = require('language-servers')
|
||||
local ensure_installed = vim.tbl_filter(function(key)
|
||||
local server = language_servers[key]
|
||||
if type(server) == 'table' then
|
||||
if server.mason ~= nil then
|
||||
return server.mason
|
||||
end
|
||||
return true
|
||||
else
|
||||
return server
|
||||
end
|
||||
end, vim.tbl_keys(language_servers))
|
||||
require('mason-lspconfig').setup({ ensure_installed = ensure_installed, auto_install = true })
|
||||
end,
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
require('lsp')
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ return {
|
||||
style = 'compact',
|
||||
filter = function(notif)
|
||||
local exact_filter = { 'No information available', 'No code actions available' }
|
||||
local contains_filter = { 'fewer lines', 'lines indented', 'lines yanked', 'more lines' }
|
||||
local contains_filter = { 'fewer lines', 'lines indented', 'lines yanked', 'more lines', 'E486:' }
|
||||
for _, msg in ipairs(exact_filter) do
|
||||
if notif.msg == msg then
|
||||
return false
|
||||
|
||||
@@ -78,7 +78,6 @@
|
||||
awatcher
|
||||
albert
|
||||
gdb
|
||||
asm-lsp
|
||||
minisign
|
||||
libisoburn
|
||||
ncdu
|
||||
@@ -100,6 +99,25 @@
|
||||
tree-sitter
|
||||
tectonic
|
||||
mermaid-cli
|
||||
|
||||
# LSP
|
||||
asm-lsp
|
||||
astro-language-server
|
||||
basedpyright
|
||||
bash-language-server
|
||||
vscode-langservers-extracted # html/css/json
|
||||
gopls
|
||||
lemminx
|
||||
lua-language-server
|
||||
markdown-oxide
|
||||
marksman
|
||||
mdx-language-server
|
||||
neocmakelsp
|
||||
nil
|
||||
tailwindcss-language-server
|
||||
taplo
|
||||
typescript-language-server
|
||||
yaml-language-server
|
||||
];
|
||||
|
||||
# For nixd LSP to recognize what nixpkgs version I use
|
||||
|
||||
Reference in New Issue
Block a user