mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
No commits in common. "fe3d5e5922f41c4d4576120808b501f4b18888d8" and "d715ce8f31d4251f2695cddf30df5b2f4908d8bd" have entirely different histories.
fe3d5e5922
...
d715ce8f31
@ -3,5 +3,3 @@ set formatoptions-=o
|
|||||||
set formatoptions-=r
|
set formatoptions-=r
|
||||||
|
|
||||||
nnoremap <buffer><silent> <F9> :luafile %<CR>
|
nnoremap <buffer><silent> <F9> :luafile %<CR>
|
||||||
|
|
||||||
nnoremap <buffer><silent> <space>f <cmd>!stylua %<CR>
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ local api = vim.api
|
|||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local lsp = vim.lsp
|
local lsp = vim.lsp
|
||||||
local diagnostic = vim.diagnostic
|
local diagnostic = vim.diagnostic
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
|
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
|
|
||||||
@ -49,13 +48,9 @@ local custom_attach = function(client, bufnr)
|
|||||||
|
|
||||||
-- Set some key bindings conditional on server capabilities
|
-- Set some key bindings conditional on server capabilities
|
||||||
if client.server_capabilities.documentFormattingProvider then
|
if client.server_capabilities.documentFormattingProvider then
|
||||||
map({"n", "x"}, "<space>f", vim.lsp.buf.format, { desc = "format code" })
|
map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
|
|
||||||
-- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
|
|
||||||
-- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
|
|
||||||
|
|
||||||
api.nvim_create_autocmd("CursorHold", {
|
api.nvim_create_autocmd("CursorHold", {
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
@ -115,97 +110,69 @@ local custom_attach = function(client, bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
-- required by nvim-ufo
|
-- required by nvim-ufo
|
||||||
capabilities.textDocument.foldingRange = {
|
capabilities.textDocument.foldingRange = {
|
||||||
dynamicRegistration = false,
|
dynamicRegistration = false,
|
||||||
lineFoldingOnly = true
|
lineFoldingOnly = true
|
||||||
}
|
}
|
||||||
|
|
||||||
-- For what diagnostic is enabled in which type checking mode, check doc:
|
local lspconfig = require("lspconfig")
|
||||||
-- 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/
|
|
||||||
|
|
||||||
if utils.executable('pyright') then
|
if utils.executable("pylsp") then
|
||||||
local new_capability = {
|
local venv_path = os.getenv('VIRTUAL_ENV')
|
||||||
-- this will remove some of the diagnostics that duplicates those from ruff, idea taken and adapted from
|
local py_path = nil
|
||||||
-- here: https://github.com/astral-sh/ruff-lsp/issues/384#issuecomment-1989619482
|
-- decide which python executable to use for mypy
|
||||||
textDocument = {
|
if venv_path ~= nil then
|
||||||
publishDiagnostics = {
|
py_path = venv_path .. "/bin/python3"
|
||||||
tagSupport = {
|
else
|
||||||
valueSet = { 2 }
|
py_path = vim.g.python3_host_prog
|
||||||
}
|
end
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
|
|
||||||
|
|
||||||
lspconfig.pyright.setup {
|
lspconfig.pylsp.setup {
|
||||||
cmd = { "delance-langserver", "--stdio" },
|
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
-- capabilities = merged_capability,
|
|
||||||
capabilities = capabilities,
|
|
||||||
settings = {
|
settings = {
|
||||||
pyright = {
|
pylsp = {
|
||||||
-- disable import sorting and use Ruff for this
|
plugins = {
|
||||||
disableOrganizeImports = true,
|
-- formatter options
|
||||||
disableTaggedHints = false,
|
black = { enabled = true },
|
||||||
},
|
autopep8 = { enabled = false },
|
||||||
python = {
|
yapf = { enabled = false },
|
||||||
analysis = {
|
-- linter options
|
||||||
autoSearchPaths = true,
|
pylint = { enabled = true, executable = "pylint" },
|
||||||
diagnosticMode = "workspace",
|
ruff = { enabled = false },
|
||||||
typeCheckingMode = "standard",
|
pyflakes = { enabled = false },
|
||||||
useLibraryCodeForTypes = true,
|
pycodestyle = { enabled = false },
|
||||||
-- we can this setting below to redefine some diagnostics
|
-- type checker
|
||||||
diagnosticSeverityOverrides = {
|
pylsp_mypy = {
|
||||||
deprecateTypingAliases = false,
|
enabled = true,
|
||||||
},
|
overrides = { "--python-executable", py_path, true },
|
||||||
-- inlay hint settings are provided by pylance?
|
report_progress = true,
|
||||||
inlayHints = {
|
live_mode = false
|
||||||
callArgumentNames = "partial",
|
|
||||||
functionReturnTypes = true,
|
|
||||||
pytestParameters = true,
|
|
||||||
variableTypes = true,
|
|
||||||
},
|
},
|
||||||
|
-- auto-completion options
|
||||||
|
jedi_completion = { fuzzy = true },
|
||||||
|
-- import sorting
|
||||||
|
isort = { enabled = true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 200,
|
||||||
|
},
|
||||||
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vim.notify("pyright not found!", vim.log.levels.WARN, { title = 'Nvim-config' })
|
vim.notify("pylsp not found!", vim.log.levels.WARN, { title = "Nvim-config" })
|
||||||
end
|
end
|
||||||
|
|
||||||
if utils.executable("ruff") then
|
-- if utils.executable('pyright') then
|
||||||
require('lspconfig').ruff.setup({
|
-- lspconfig.pyright.setup{
|
||||||
on_attach = custom_attach,
|
-- on_attach = custom_attach,
|
||||||
capabilities = capabilities,
|
-- capabilities = capabilities
|
||||||
init_options = {
|
-- }
|
||||||
-- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
|
-- else
|
||||||
settings = {
|
-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
|
||||||
organizeImports = true,
|
-- end
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Disable ruff hover feature in favor of Pyright
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
|
||||||
group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }),
|
|
||||||
callback = function(args)
|
|
||||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
||||||
-- vim.print(client.name, client.server_capabilities)
|
|
||||||
|
|
||||||
if client == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if client.name == 'ruff' then
|
|
||||||
client.server_capabilities.hoverProvider = false
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
desc = 'LSP: Disable hover capability from Ruff',
|
|
||||||
})
|
|
||||||
|
|
||||||
if utils.executable("ltex-ls") then
|
if utils.executable("ltex-ls") then
|
||||||
lspconfig.ltex.setup {
|
lspconfig.ltex.setup {
|
||||||
@ -253,8 +220,8 @@ if utils.executable("bash-language-server") then
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
|
|
||||||
if utils.executable("lua-language-server") then
|
if utils.executable("lua-language-server") then
|
||||||
|
-- settings for lua-language-server can be found on https://github.com/LuaLS/lua-language-server/wiki/Settings .
|
||||||
lspconfig.lua_ls.setup {
|
lspconfig.lua_ls.setup {
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
settings = {
|
settings = {
|
||||||
@ -263,9 +230,6 @@ if utils.executable("lua-language-server") then
|
|||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||||
version = "LuaJIT",
|
version = "LuaJIT",
|
||||||
},
|
},
|
||||||
hint = {
|
|
||||||
enable = true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
|||||||
@ -357,6 +357,9 @@ local plugin_specs = {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- Better git commit experience
|
||||||
|
{ "rhysd/committia.vim", lazy = true },
|
||||||
|
|
||||||
{
|
{
|
||||||
"sindrets/diffview.nvim",
|
"sindrets/diffview.nvim",
|
||||||
},
|
},
|
||||||
@ -570,14 +573,6 @@ local plugin_specs = {
|
|||||||
end,
|
end,
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
-- show hint for code actions, the user can also implement code actions themselves,
|
|
||||||
-- see discussion here: https://github.com/neovim/neovim/issues/14869
|
|
||||||
"kosayoda/nvim-lightbulb",
|
|
||||||
config = function()
|
|
||||||
require("nvim-lightbulb").setup { autocmd = { enabled = true } }
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require("lazy").setup {
|
require("lazy").setup {
|
||||||
|
|||||||
@ -79,7 +79,7 @@ let g:Lf_WorkingDirectoryMode = 'a'
|
|||||||
nnoremap <silent> <leader>ff :<C-U>Leaderf file --popup<CR>
|
nnoremap <silent> <leader>ff :<C-U>Leaderf file --popup<CR>
|
||||||
|
|
||||||
" Grep project files in popup window
|
" Grep project files in popup window
|
||||||
nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup --nameOnly<CR>
|
nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup<CR>
|
||||||
|
|
||||||
" Search vim help files
|
" Search vim help files
|
||||||
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>
|
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user