mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
5 Commits
488ba52644
...
ea23f913b4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea23f913b4 | ||
|
|
8839201450 | ||
|
|
ba991064b6 | ||
|
|
6c620ecc32 | ||
|
|
be862a83d6 |
@ -10,7 +10,7 @@
|
|||||||
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
|
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
||||||
<img src="https://img.shields.io/badge/Neovim-0.11.0-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
<img src="https://img.shields.io/badge/Neovim-0.11.1-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/jdhao/nvim-config/releases/latest">
|
<a href="https://github.com/jdhao/nvim-config/releases/latest">
|
||||||
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
||||||
|
|||||||
3
after/lsp/clangd.lua
Normal file
3
after/lsp/clangd.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
return {
|
||||||
|
filetypes = { "c", "cpp", "cc" },
|
||||||
|
}
|
||||||
8
after/lsp/ltex.lua
Normal file
8
after/lsp/ltex.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
filetypes = { "text", "plaintex", "tex", "markdown" },
|
||||||
|
settings = {
|
||||||
|
ltex = {
|
||||||
|
language = "en",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
14
after/lsp/lua_ls.lua
Normal file
14
after/lsp/lua_ls.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
|
||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||||
|
version = "LuaJIT",
|
||||||
|
},
|
||||||
|
hint = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
51
after/lsp/pyright.lua
Normal file
51
after/lsp/pyright.lua
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
-- For what diagnostic is enabled in which type checking mode, check doc:
|
||||||
|
-- https://github.com/microsoft/pyright/blob/main/docs/configuration.md#diagnostic-settings-defaults
|
||||||
|
-- Currently, the pyright also has some issues displaying hover documentation:
|
||||||
|
-- https://www.reddit.com/r/neovim/comments/1gdv1rc/what_is_causeing_the_lsp_hover_docs_to_looks_like/
|
||||||
|
|
||||||
|
local new_capability = {
|
||||||
|
-- this will remove some of the diagnostics that duplicates those from ruff, idea taken and adapted from
|
||||||
|
-- here: https://github.com/astral-sh/ruff-lsp/issues/384#issuecomment-1989619482
|
||||||
|
textDocument = {
|
||||||
|
publishDiagnostics = {
|
||||||
|
tagSupport = {
|
||||||
|
valueSet = { 2 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hover = {
|
||||||
|
contentFormat = { "plaintext" },
|
||||||
|
dynamicRegistration = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
cmd = { "delance-langserver", "--stdio" },
|
||||||
|
settings = {
|
||||||
|
pyright = {
|
||||||
|
-- disable import sorting and use Ruff for this
|
||||||
|
disableOrganizeImports = true,
|
||||||
|
disableTaggedHints = false,
|
||||||
|
},
|
||||||
|
python = {
|
||||||
|
analysis = {
|
||||||
|
autoSearchPaths = true,
|
||||||
|
diagnosticMode = "workspace",
|
||||||
|
typeCheckingMode = "standard",
|
||||||
|
useLibraryCodeForTypes = true,
|
||||||
|
-- we can this setting below to redefine some diagnostics
|
||||||
|
diagnosticSeverityOverrides = {
|
||||||
|
deprecateTypingAliases = false,
|
||||||
|
},
|
||||||
|
-- inlay hint settings are provided by pylance?
|
||||||
|
inlayHints = {
|
||||||
|
callArgumentNames = "partial",
|
||||||
|
functionReturnTypes = true,
|
||||||
|
pytestParameters = true,
|
||||||
|
variableTypes = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
capabilities = new_capability,
|
||||||
|
}
|
||||||
8
after/lsp/ruff.lua
Normal file
8
after/lsp/ruff.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
init_options = {
|
||||||
|
-- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
|
||||||
|
settings = {
|
||||||
|
organizeImports = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
2
init.lua
2
init.lua
@ -13,7 +13,7 @@ vim.loader.enable()
|
|||||||
|
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
|
|
||||||
local expected_version = "0.11.0"
|
local expected_version = "0.11.1"
|
||||||
utils.is_compatible_version(expected_version)
|
utils.is_compatible_version(expected_version)
|
||||||
|
|
||||||
local config_dir = vim.fn.stdpath("config")
|
local config_dir = vim.fn.stdpath("config")
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
group = vim.api.nvim_create_augroup("buf_behavior_conf", { clear = true }),
|
group = vim.api.nvim_create_augroup("lsp_buf_conf", { clear = true }),
|
||||||
callback = function(event_context)
|
callback = function(event_context)
|
||||||
local client = vim.lsp.get_client_by_id(event_context.data.client_id)
|
local client = vim.lsp.get_client_by_id(event_context.data.client_id)
|
||||||
-- vim.print(client.name, client.server_capabilities)
|
-- vim.print(client.name, client.server_capabilities)
|
||||||
@ -72,151 +72,37 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||||||
desc = "Configure buffer keymap and behavior based on LSP",
|
desc = "Configure buffer keymap and behavior based on LSP",
|
||||||
})
|
})
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
-- Enable lsp servers when they are available
|
||||||
|
|
||||||
-- required by nvim-ufo
|
local capabilities = require("lsp_utils").get_default_capabilities()
|
||||||
capabilities.textDocument.foldingRange = {
|
|
||||||
dynamicRegistration = false,
|
vim.lsp.config("*", {
|
||||||
lineFoldingOnly = true,
|
capabilities = capabilities,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 500,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- A mapping from lsp server name to the executable name
|
||||||
|
local enabled_lsp_servers = {
|
||||||
|
pyright = "delance-langserver",
|
||||||
|
ruff = "ruff",
|
||||||
|
lua_ls = "lua-language-server",
|
||||||
|
-- ltex = "ltex-ls",
|
||||||
|
-- clangd = "clangd",
|
||||||
|
vimls = "vim-language-server",
|
||||||
|
bashls = "bash-language-server",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- For what diagnostic is enabled in which type checking mode, check doc:
|
for server_name, lsp_executable in pairs(enabled_lsp_servers) do
|
||||||
-- https://github.com/microsoft/pyright/blob/main/docs/configuration.md#diagnostic-settings-defaults
|
if utils.executable(lsp_executable) then
|
||||||
-- Currently, the pyright also has some issues displaying hover documentation:
|
vim.lsp.enable(server_name)
|
||||||
-- https://www.reddit.com/r/neovim/comments/1gdv1rc/what_is_causeing_the_lsp_hover_docs_to_looks_like/
|
else
|
||||||
|
local msg = string.format(
|
||||||
if utils.executable("pyright") then
|
"Executable '%s' for server '%s' not found! Server will not be enabled",
|
||||||
local new_capability = {
|
lsp_executable,
|
||||||
-- this will remove some of the diagnostics that duplicates those from ruff, idea taken and adapted from
|
server_name
|
||||||
-- here: https://github.com/astral-sh/ruff-lsp/issues/384#issuecomment-1989619482
|
)
|
||||||
textDocument = {
|
vim.notify(msg, vim.log.levels.WARN, { title = "Nvim-config" })
|
||||||
publishDiagnostics = {
|
end
|
||||||
tagSupport = {
|
|
||||||
valueSet = { 2 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
hover = {
|
|
||||||
contentFormat = { "plaintext" },
|
|
||||||
dynamicRegistration = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
|
|
||||||
|
|
||||||
vim.lsp.config("pyright", {
|
|
||||||
cmd = { "delance-langserver", "--stdio" },
|
|
||||||
capabilities = merged_capability,
|
|
||||||
settings = {
|
|
||||||
pyright = {
|
|
||||||
-- disable import sorting and use Ruff for this
|
|
||||||
disableOrganizeImports = true,
|
|
||||||
disableTaggedHints = false,
|
|
||||||
},
|
|
||||||
python = {
|
|
||||||
analysis = {
|
|
||||||
autoSearchPaths = true,
|
|
||||||
diagnosticMode = "workspace",
|
|
||||||
typeCheckingMode = "standard",
|
|
||||||
useLibraryCodeForTypes = true,
|
|
||||||
-- we can this setting below to redefine some diagnostics
|
|
||||||
diagnosticSeverityOverrides = {
|
|
||||||
deprecateTypingAliases = false,
|
|
||||||
},
|
|
||||||
-- inlay hint settings are provided by pylance?
|
|
||||||
inlayHints = {
|
|
||||||
callArgumentNames = "partial",
|
|
||||||
functionReturnTypes = true,
|
|
||||||
pytestParameters = true,
|
|
||||||
variableTypes = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.enable("pyright")
|
|
||||||
else
|
|
||||||
vim.notify("pyright not found!", vim.log.levels.WARN, { title = "Nvim-config" })
|
|
||||||
end
|
|
||||||
|
|
||||||
if utils.executable("ruff") then
|
|
||||||
vim.lsp.config("ruff", {
|
|
||||||
capabilities = capabilities,
|
|
||||||
init_options = {
|
|
||||||
-- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
|
|
||||||
settings = {
|
|
||||||
organizeImports = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
vim.lsp.enable("ruff")
|
|
||||||
end
|
|
||||||
|
|
||||||
if utils.executable("ltex-ls") then
|
|
||||||
vim.lsp.config("ltex", {
|
|
||||||
filetypes = { "text", "plaintex", "tex", "markdown" },
|
|
||||||
settings = {
|
|
||||||
ltex = {
|
|
||||||
language = "en",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
flags = { debounce_text_changes = 300 },
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.enable("ltex")
|
|
||||||
end
|
|
||||||
|
|
||||||
if utils.executable("clangd") then
|
|
||||||
vim.lsp.config("clangd", {
|
|
||||||
capabilities = capabilities,
|
|
||||||
filetypes = { "c", "cpp", "cc" },
|
|
||||||
flags = {
|
|
||||||
debounce_text_changes = 500,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.enable("clangd")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set up vim-language-server
|
|
||||||
if utils.executable("vim-language-server") then
|
|
||||||
vim.lsp.config("vimls", {
|
|
||||||
flags = {
|
|
||||||
debounce_text_changes = 500,
|
|
||||||
},
|
|
||||||
capabilities = capabilities,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.enable("vimls")
|
|
||||||
else
|
|
||||||
vim.notify("vim-language-server not found!", vim.log.levels.WARN, { title = "Nvim-config" })
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set up bash-language-server
|
|
||||||
if utils.executable("bash-language-server") then
|
|
||||||
vim.lsp.config("bashls", {
|
|
||||||
capabilities = capabilities,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.enable("bashls")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
|
|
||||||
if utils.executable("lua-language-server") then
|
|
||||||
vim.lsp.config("lua_ls", {
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
runtime = {
|
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
||||||
version = "LuaJIT",
|
|
||||||
},
|
|
||||||
hint = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
capabilities = capabilities,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.enable("lua_ls")
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -210,7 +210,7 @@ require("lualine").setup {
|
|||||||
disabled_filetypes = {},
|
disabled_filetypes = {},
|
||||||
always_divide_middle = true,
|
always_divide_middle = true,
|
||||||
refresh = {
|
refresh = {
|
||||||
statusline = 500,
|
statusline = 1000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
|
|||||||
15
lua/lsp_utils.lua
Normal file
15
lua/lsp_utils.lua
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.get_default_capabilities = function()
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
|
||||||
|
-- required by nvim-ufo
|
||||||
|
capabilities.textDocument.foldingRange = {
|
||||||
|
dynamicRegistration = false,
|
||||||
|
lineFoldingOnly = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
return capabilities
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
Loading…
x
Reference in New Issue
Block a user