mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
18 Commits
ad4a0e82dc
...
v0.11.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
082111fa4e | ||
|
|
30b3c09dda | ||
|
|
3b964c3d1f | ||
|
|
999a1733cf | ||
|
|
b69dcb3a6b | ||
|
|
ea23f913b4 | ||
|
|
8839201450 | ||
|
|
ba991064b6 | ||
|
|
6c620ecc32 | ||
|
|
be862a83d6 | ||
|
|
488ba52644 | ||
|
|
e23d4bb661 | ||
|
|
510a5501c5 | ||
|
|
e08b17f335 | ||
|
|
adddbc0ba6 | ||
|
|
aadfdae677 | ||
|
|
5826161160 | ||
|
|
ea2b4a728d |
12
README.md
12
README.md
@@ -10,10 +10,7 @@
|
||||
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
|
||||
</a>
|
||||
<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"/>
|
||||
</a>
|
||||
<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 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 href="https://github.com/jdhao/nvim-config/search?l=vim-script">
|
||||
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
|
||||
@@ -69,7 +66,6 @@ and how to set up on different platforms (Linux, macOS, and Windows).
|
||||
+ File tree explorer via [nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua).
|
||||
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
|
||||
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
|
||||
+ Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim).
|
||||
+ User-defined mapping hint via [which-key.nvim](https://github.com/folke/which-key.nvim).
|
||||
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
|
||||
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
||||
@@ -111,12 +107,6 @@ For more UI demos, check [here](https://github.com/jdhao/nvim-config/issues/15).
|
||||
<img src="https://user-images.githubusercontent.com/16662357/128590833-aaa05d53-19ef-441d-a5a9-ba1bbd3936c1.gif" width="800">
|
||||
</p>
|
||||
|
||||
## Command-line autocompletion with wilder.nvim
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/16662357/147677787-8e5d229a-a16a-420e-98f5-88f2a1be84a2.gif" width="800">
|
||||
</p>
|
||||
|
||||
## Tags
|
||||
|
||||
<p align="center">
|
||||
|
||||
@@ -12,3 +12,5 @@ set tabstop=4 " number of visual spaces per TAB
|
||||
set softtabstop=4 " number of spaces in tab when editing
|
||||
set shiftwidth=4 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
|
||||
nnoremap <buffer><silent> <space>f <cmd>silent !black %<CR>
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -221,7 +221,7 @@ fi
|
||||
NVIM_DIR=$HOME/tools/nvim
|
||||
NVIM_SRC_NAME=$HOME/packages/nvim-linux64.tar.gz
|
||||
NVIM_CONFIG_DIR=$HOME/.config/nvim
|
||||
NVIM_LINK="https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz"
|
||||
NVIM_LINK="https://github.com/neovim/neovim/releases/download/stable/nvim-linux-x86_64.tar.gz"
|
||||
if [[ ! -f "$NVIM_DIR/bin/nvim" ]]; then
|
||||
echo "Installing Nvim"
|
||||
echo "Creating nvim directory under tools directory"
|
||||
|
||||
2
init.lua
2
init.lua
@@ -13,7 +13,7 @@ vim.loader.enable()
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
local expected_version = "0.11.0"
|
||||
local expected_version = "0.11.1"
|
||||
utils.is_compatible_version(expected_version)
|
||||
|
||||
local config_dir = vim.fn.stdpath("config")
|
||||
|
||||
18
lua/config/fzf-lua.lua
Normal file
18
lua/config/fzf-lua.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
require("fzf-lua").setup {
|
||||
defaults = {
|
||||
file_icons = "mini",
|
||||
},
|
||||
winopts = {
|
||||
row = 0.5,
|
||||
height = 0.7,
|
||||
},
|
||||
files = {
|
||||
previewer = false,
|
||||
},
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "<leader>ff", "<cmd>FzfLua files<cr>", { desc = "Fuzzy find files" })
|
||||
vim.keymap.set("n", "<leader>fg", "<cmd>FzfLua live_grep<cr>", { desc = "Fuzzy grep files" })
|
||||
vim.keymap.set("n", "<leader>fh", "<cmd>FzfLua helptags<cr>", { desc = "Fuzzy grep tags in help files" })
|
||||
vim.keymap.set("n", "<leader>ft", "<cmd>FzfLua btags<cr>", { desc = "Fuzzy search buffer tags" })
|
||||
vim.keymap.set("n", "<leader>fb", "<cmd>FzfLua buffers<cr>", { desc = "Fuzzy search opened buffers" })
|
||||
12
lua/config/git-conflict.lua
Normal file
12
lua/config/git-conflict.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
require("git-conflict").setup {}
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "GitConflictResolved",
|
||||
callback = function()
|
||||
-- clear qf list
|
||||
vim.fn.setqflist({}, "r")
|
||||
|
||||
-- reopen it?
|
||||
vim.cmd([[GitConflictListQf]])
|
||||
end,
|
||||
})
|
||||
@@ -1,36 +0,0 @@
|
||||
local api = vim.api
|
||||
|
||||
local exclude_ft = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha", "dashboard" }
|
||||
|
||||
require("ibl").setup {
|
||||
indent = {
|
||||
-- -- U+2502 may also be a good choice, it will be on the middle of cursor.
|
||||
-- -- U+250A is also a good choice
|
||||
char = "▏",
|
||||
},
|
||||
scope = {
|
||||
show_start = false,
|
||||
show_end = false,
|
||||
},
|
||||
exclude = {
|
||||
filetypes = exclude_ft,
|
||||
buftypes = { "terminal" },
|
||||
},
|
||||
}
|
||||
|
||||
local gid = api.nvim_create_augroup("indent_blankline", { clear = true })
|
||||
api.nvim_create_autocmd("InsertEnter", {
|
||||
pattern = "*",
|
||||
group = gid,
|
||||
command = "IBLDisable",
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd("InsertLeave", {
|
||||
pattern = "*",
|
||||
group = gid,
|
||||
callback = function()
|
||||
if not vim.tbl_contains(exclude_ft, vim.bo.filetype) then
|
||||
vim.cmd([[IBLEnable]])
|
||||
end
|
||||
end,
|
||||
})
|
||||
@@ -1,12 +1,7 @@
|
||||
local api = vim.api
|
||||
local keymap = vim.keymap
|
||||
local lsp = vim.lsp
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
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)
|
||||
local client = vim.lsp.get_client_by_id(event_context.data.client_id)
|
||||
-- vim.print(client.name, client.server_capabilities)
|
||||
@@ -22,10 +17,48 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
opts = opts or {}
|
||||
opts.silent = true
|
||||
opts.buffer = bufnr
|
||||
keymap.set(mode, l, r, opts)
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
|
||||
map("n", "gd", function()
|
||||
vim.lsp.buf.definition {
|
||||
on_list = function(options)
|
||||
-- custom logic to avoid showing multiple definition when you use this style of code:
|
||||
-- `local M.my_fn_name = function() ... end`.
|
||||
-- See also post here: https://www.reddit.com/r/neovim/comments/19cvgtp/any_way_to_remove_redundant_definition_in_lua_file/
|
||||
|
||||
-- vim.print(options.items)
|
||||
local unique_defs = {}
|
||||
local def_loc_hash = {}
|
||||
|
||||
-- each item in options.items contain the location info for a definition provided by LSP server
|
||||
for _, def_location in pairs(options.items) do
|
||||
-- use filename and line number to uniquelly indentify a definition,
|
||||
-- we do not expect/want multiple definition in single line!
|
||||
local hash_key = def_location.filename .. def_location.lnum
|
||||
|
||||
if not def_loc_hash[hash_key] then
|
||||
def_loc_hash[hash_key] = true
|
||||
table.insert(unique_defs, def_location)
|
||||
end
|
||||
end
|
||||
|
||||
options.items = unique_defs
|
||||
|
||||
-- set the location list
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
vim.fn.setloclist(0, {}, " ", options)
|
||||
|
||||
-- open the location list when we have more than 1 definitions found,
|
||||
-- otherwise, jump directly to the definition
|
||||
if #options.items > 1 then
|
||||
vim.cmd.lopen()
|
||||
else
|
||||
vim.cmd([[silent! lfirst]])
|
||||
end
|
||||
end,
|
||||
}
|
||||
end, { desc = "go to definition" })
|
||||
map("n", "<C-]>", vim.lsp.buf.definition)
|
||||
map("n", "K", function()
|
||||
vim.lsp.buf.hover { border = "single", max_height = 25, max_width = 120 }
|
||||
@@ -40,10 +73,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
end, { desc = "list workspace folder" })
|
||||
|
||||
-- Set some key bindings conditional on server capabilities
|
||||
if client.server_capabilities.documentFormattingProvider and client.name ~= "lua_ls" then
|
||||
map({ "n", "x" }, "<space>f", vim.lsp.buf.format, { desc = "format code" })
|
||||
end
|
||||
|
||||
-- Disable ruff hover feature in favor of Pyright
|
||||
if client.name == "ruff" then
|
||||
client.server_capabilities.hoverProvider = false
|
||||
@@ -55,20 +84,20 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
|
||||
-- The blow command will highlight the current variable and its usages in the buffer.
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||
api.nvim_create_autocmd("CursorHold", {
|
||||
local gid = vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
group = gid,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
lsp.buf.document_highlight()
|
||||
vim.lsp.buf.document_highlight()
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd("CursorMoved", {
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
group = gid,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
lsp.buf.clear_references()
|
||||
vim.lsp.buf.clear_references()
|
||||
end,
|
||||
})
|
||||
end
|
||||
@@ -77,139 +106,38 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
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
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true,
|
||||
local capabilities = require("lsp_utils").get_default_capabilities()
|
||||
|
||||
vim.lsp.config("*", {
|
||||
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",
|
||||
yamlls = "yaml-language-server",
|
||||
}
|
||||
|
||||
-- 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/
|
||||
|
||||
if utils.executable("pyright") then
|
||||
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,
|
||||
},
|
||||
},
|
||||
}
|
||||
local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
|
||||
|
||||
lspconfig.pyright.setup {
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
else
|
||||
vim.notify("pyright not found!", vim.log.levels.WARN, { title = "Nvim-config" })
|
||||
end
|
||||
|
||||
if utils.executable("ruff") then
|
||||
require("lspconfig").ruff.setup {
|
||||
capabilities = capabilities,
|
||||
init_options = {
|
||||
-- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
|
||||
settings = {
|
||||
organizeImports = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
if utils.executable("ltex-ls") then
|
||||
lspconfig.ltex.setup {
|
||||
cmd = { "ltex-ls" },
|
||||
filetypes = { "text", "plaintex", "tex", "markdown" },
|
||||
settings = {
|
||||
ltex = {
|
||||
language = "en",
|
||||
},
|
||||
},
|
||||
flags = { debounce_text_changes = 300 },
|
||||
}
|
||||
end
|
||||
|
||||
if utils.executable("clangd") then
|
||||
lspconfig.clangd.setup {
|
||||
capabilities = capabilities,
|
||||
filetypes = { "c", "cpp", "cc" },
|
||||
flags = {
|
||||
debounce_text_changes = 500,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
-- set up vim-language-server
|
||||
if utils.executable("vim-language-server") then
|
||||
lspconfig.vimls.setup {
|
||||
flags = {
|
||||
debounce_text_changes = 500,
|
||||
},
|
||||
capabilities = capabilities,
|
||||
}
|
||||
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
|
||||
lspconfig.bashls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
|
||||
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
|
||||
if utils.executable("lua-language-server") then
|
||||
lspconfig.lua_ls.setup {
|
||||
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,
|
||||
}
|
||||
for server_name, lsp_executable in pairs(enabled_lsp_servers) do
|
||||
if utils.executable(lsp_executable) then
|
||||
vim.lsp.enable(server_name)
|
||||
else
|
||||
local msg = string.format(
|
||||
"Executable '%s' for server '%s' not found! Server will not be enabled",
|
||||
lsp_executable,
|
||||
server_name
|
||||
)
|
||||
vim.notify(msg, vim.log.levels.WARN, { title = "Nvim-config" })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -210,7 +210,7 @@ require("lualine").setup {
|
||||
disabled_filetypes = {},
|
||||
always_divide_middle = true,
|
||||
refresh = {
|
||||
statusline = 500,
|
||||
statusline = 1000,
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
-- Setup nvim-cmp.
|
||||
local cmp = require("cmp")
|
||||
local lspkind = require("lspkind")
|
||||
|
||||
-- The extentions needed by nvim-cmp should be loaded beforehand
|
||||
require("cmp_nvim_lsp")
|
||||
require("cmp_path")
|
||||
require("cmp_buffer")
|
||||
require("cmp_omni")
|
||||
require("cmp_nvim_ultisnips")
|
||||
require("cmp_cmdline")
|
||||
|
||||
local MiniIcons = require("mini.icons")
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
@@ -43,21 +52,14 @@ cmp.setup {
|
||||
view = {
|
||||
entries = "custom",
|
||||
},
|
||||
-- solution taken from https://github.com/echasnovski/mini.nvim/issues/1007#issuecomment-2258929830
|
||||
formatting = {
|
||||
format = lspkind.cmp_format {
|
||||
mode = "symbol_text",
|
||||
menu = {
|
||||
nvim_lsp = "[LSP]",
|
||||
ultisnips = "[US]",
|
||||
path = "[Path]",
|
||||
buffer = "[Buffer]",
|
||||
emoji = "[Emoji]",
|
||||
omni = "[Omni]",
|
||||
},
|
||||
show_labelDetails = true,
|
||||
maxwidth = 40,
|
||||
ellipsis_char = "...",
|
||||
},
|
||||
format = function(_, vim_item)
|
||||
local icon, hl = MiniIcons.get("lsp", vim_item.kind)
|
||||
vim_item.kind = icon .. " " .. vim_item.kind
|
||||
vim_item.kind_hl_group = hl
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -70,6 +72,23 @@ cmp.setup.filetype("tex", {
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.cmdline("/", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(":", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false },
|
||||
})
|
||||
|
||||
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
|
||||
vim.cmd([[
|
||||
highlight! link CmpItemMenu Comment
|
||||
|
||||
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
|
||||
@@ -104,7 +104,7 @@ keymap.set("n", "<leader>v", "printf('`[%s`]', getregtype()[0])", {
|
||||
})
|
||||
|
||||
-- Always use very magic mode for searching
|
||||
keymap.set("n", "/", [[/\v]])
|
||||
-- keymap.set("n", "/", [[/\v]])
|
||||
|
||||
-- Search in selected region
|
||||
-- xnoremap / :<C-U>call feedkeys('/\%>'.(line("'<")-1).'l\%<'.(line("'>")+1)."l")<CR>
|
||||
|
||||
@@ -22,24 +22,83 @@ end
|
||||
|
||||
local plugin_specs = {
|
||||
-- auto-completion engine
|
||||
{ "hrsh7th/cmp-nvim-lsp", lazy = true },
|
||||
{ "hrsh7th/cmp-path", lazy = true },
|
||||
{ "hrsh7th/cmp-buffer", lazy = true },
|
||||
{ "hrsh7th/cmp-omni", lazy = true },
|
||||
{ "hrsh7th/cmp-cmdline", lazy = true },
|
||||
{ "quangnguyen30192/cmp-nvim-ultisnips", lazy = true },
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
name = "nvim-cmp",
|
||||
-- event = 'InsertEnter',
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"onsails/lspkind-nvim",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-omni",
|
||||
"quangnguyen30192/cmp-nvim-ultisnips",
|
||||
},
|
||||
config = function()
|
||||
require("config.nvim-cmp")
|
||||
end,
|
||||
},
|
||||
--{
|
||||
-- "saghen/blink.cmp",
|
||||
-- -- optional: provides snippets for the snippet source
|
||||
-- dependencies = { "rafamadriz/friendly-snippets" },
|
||||
|
||||
-- -- use a release tag to download pre-built binaries
|
||||
-- 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
|
||||
-- --
|
||||
-- keymap = {
|
||||
-- preset = "default",
|
||||
-- ["<Tab>"] = { "select_next", "fallback" },
|
||||
-- ["<S-Tab>"] = { "select_prev", "fallback" },
|
||||
-- ["<Enter>"] = { "select_and_accept", "fallback" },
|
||||
-- ["<C-U>"] = { "scroll_documentation_up", "fallback" },
|
||||
-- ["<C-D>"] = { "scroll_documentation_down", "fallback" },
|
||||
-- },
|
||||
|
||||
-- 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 = true,
|
||||
-- },
|
||||
-- },
|
||||
|
||||
-- -- 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", "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" },
|
||||
-- cmdline = {
|
||||
-- completion = {
|
||||
-- menu = {
|
||||
-- auto_show = true,
|
||||
-- },
|
||||
-- },
|
||||
-- keymap = {
|
||||
-- ["<Enter>"] = { "select_and_accept", "fallback" },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- opts_extend = { "sources.default" },
|
||||
--},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufRead", "BufNewFile" },
|
||||
@@ -56,7 +115,7 @@ local plugin_specs = {
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
event = "VeryLazy",
|
||||
lazy = true,
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require("config.treesitter")
|
||||
@@ -88,7 +147,7 @@ local plugin_specs = {
|
||||
-- Super fast buffer jump
|
||||
{
|
||||
"smoka7/hop.nvim",
|
||||
event = "VeryLazy",
|
||||
keys = { "f" },
|
||||
config = function()
|
||||
require("config.nvim_hop")
|
||||
end,
|
||||
@@ -112,28 +171,16 @@ local plugin_specs = {
|
||||
},
|
||||
{
|
||||
"ibhagwan/fzf-lua",
|
||||
-- optional for icon support
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("fzf-lua").setup {
|
||||
winopts = {
|
||||
row = 0.5,
|
||||
height = 0.7,
|
||||
},
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "<leader>ff", "<cmd>FzfLua files<cr>", { desc = "Fuzzy find files" })
|
||||
vim.keymap.set("n", "<leader>fg", "<cmd>FzfLua live_grep<cr>", { desc = "Fuzzy grep files" })
|
||||
vim.keymap.set("n", "<leader>fh", "<cmd>FzfLua helptags<cr>", { desc = "Fuzzy grep tags in help files" })
|
||||
vim.keymap.set("n", "<leader>ft", "<cmd>FzfLua btags<cr>", { desc = "Fuzzy search buffer tags" })
|
||||
vim.keymap.set("n", "<leader>fb", "<cmd>FzfLua buffers<cr>", { desc = "Fuzzy search opened buffers" })
|
||||
require("config.fzf-lua")
|
||||
end,
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
"MeanderingProgrammer/markdown.nvim",
|
||||
main = "render-markdown",
|
||||
opts = {},
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" },
|
||||
ft = { "markdown" },
|
||||
},
|
||||
-- A list of colorscheme plugin you may want to try. Find what suits you.
|
||||
{ "navarasu/onedark.nvim", lazy = true },
|
||||
@@ -152,11 +199,22 @@ local plugin_specs = {
|
||||
branch = "v2",
|
||||
},
|
||||
{ "rebelot/kanagawa.nvim", lazy = true },
|
||||
{ "nvim-tree/nvim-web-devicons", event = "VeryLazy" },
|
||||
|
||||
-- plugins to provide nerdfont icons
|
||||
{
|
||||
"echasnovski/mini.icons",
|
||||
version = false,
|
||||
config = function()
|
||||
-- this is the compatibility fix for plugins that only support nvim-web-devicons
|
||||
require("mini.icons").mock_nvim_web_devicons()
|
||||
require("mini.icons").tweak_lsp_kind()
|
||||
end,
|
||||
lazy = true,
|
||||
},
|
||||
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
event = "BufRead",
|
||||
cond = firenvim_not_active,
|
||||
config = function()
|
||||
require("config.lualine")
|
||||
@@ -182,11 +240,16 @@ local plugin_specs = {
|
||||
},
|
||||
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
event = "VeryLazy",
|
||||
main = "ibl",
|
||||
"echasnovski/mini.indentscope",
|
||||
version = false,
|
||||
config = function()
|
||||
require("config.indent-blankline")
|
||||
local mini_indent = require("mini.indentscope")
|
||||
mini_indent.setup {
|
||||
draw = {
|
||||
animation = mini_indent.gen_animation.none(),
|
||||
},
|
||||
symbol = "▏",
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
@@ -212,7 +275,7 @@ local plugin_specs = {
|
||||
end,
|
||||
},
|
||||
-- Highlight URLs inside vim
|
||||
{ "itchyny/vim-highlighturl", event = "VeryLazy" },
|
||||
{ "itchyny/vim-highlighturl", event = "BufReadPost" },
|
||||
|
||||
-- notification plugin
|
||||
{
|
||||
@@ -223,6 +286,8 @@ local plugin_specs = {
|
||||
end,
|
||||
},
|
||||
|
||||
{ "nvim-lua/plenary.nvim", lazy = true },
|
||||
|
||||
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may
|
||||
-- not be possible since we maybe in a server which disables GUI.
|
||||
{
|
||||
@@ -235,7 +300,6 @@ local plugin_specs = {
|
||||
enabled = function()
|
||||
return vim.g.is_win or vim.g.is_mac
|
||||
end,
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = true, -- default settings
|
||||
submodules = false, -- not needed, submodules are required only for tests
|
||||
},
|
||||
@@ -251,9 +315,13 @@ local plugin_specs = {
|
||||
},
|
||||
|
||||
-- Snippet engine and snippet template
|
||||
{ "SirVer/ultisnips", dependencies = {
|
||||
"honza/vim-snippets",
|
||||
}, event = "InsertEnter" },
|
||||
{
|
||||
"SirVer/ultisnips",
|
||||
dependencies = {
|
||||
"honza/vim-snippets",
|
||||
},
|
||||
event = "InsertEnter",
|
||||
},
|
||||
|
||||
-- Automatic insertion and deletion of a pair of characters
|
||||
{
|
||||
@@ -263,7 +331,13 @@ local plugin_specs = {
|
||||
},
|
||||
|
||||
-- Comment plugin
|
||||
{ "tpope/vim-commentary", event = "VeryLazy" },
|
||||
{
|
||||
"tpope/vim-commentary",
|
||||
keys = {
|
||||
{ "gc", mode = "n" },
|
||||
{ "gc", mode = "v" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Multiple cursor plugin like Sublime Text?
|
||||
-- 'mg979/vim-visual-multi'
|
||||
@@ -277,7 +351,7 @@ local plugin_specs = {
|
||||
config = function()
|
||||
require("config.yanky")
|
||||
end,
|
||||
event = "VeryLazy",
|
||||
cmd = "YankyRingHistory",
|
||||
},
|
||||
|
||||
-- Handy unix command inside Vim (Rename, Move etc.)
|
||||
@@ -304,9 +378,6 @@ local plugin_specs = {
|
||||
event = { "InsertEnter" },
|
||||
},
|
||||
|
||||
-- Auto format tools
|
||||
{ "sbdchd/neoformat", cmd = { "Neoformat" } },
|
||||
|
||||
-- Git command inside vim
|
||||
{
|
||||
"tpope/vim-fugitive",
|
||||
@@ -318,7 +389,14 @@ local plugin_specs = {
|
||||
|
||||
-- Better git log display
|
||||
{ "rbong/vim-flog", cmd = { "Flog" } },
|
||||
{ "akinsho/git-conflict.nvim", version = "*", config = true },
|
||||
{
|
||||
"akinsho/git-conflict.nvim",
|
||||
version = "*",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("config.git-conflict")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"ruifm/gitlinker.nvim",
|
||||
event = "User InGitRepo",
|
||||
@@ -333,10 +411,12 @@ local plugin_specs = {
|
||||
config = function()
|
||||
require("config.gitsigns")
|
||||
end,
|
||||
event = "BufRead",
|
||||
},
|
||||
|
||||
{
|
||||
"sindrets/diffview.nvim",
|
||||
cmd = { "DiffviewOpen" },
|
||||
},
|
||||
|
||||
{
|
||||
@@ -347,9 +427,6 @@ local plugin_specs = {
|
||||
end,
|
||||
},
|
||||
|
||||
-- Another markdown plugin
|
||||
-- { "preservim/vim-markdown", ft = { "markdown" } },
|
||||
|
||||
-- Faster footnote generation
|
||||
{ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } },
|
||||
|
||||
@@ -374,7 +451,7 @@ local plugin_specs = {
|
||||
ft = { "markdown" },
|
||||
},
|
||||
|
||||
{ "chrisbra/unicode.vim", event = "VeryLazy" },
|
||||
{ "chrisbra/unicode.vim", keys = { "ga" }, cmd = { "UnicodeSearch" } },
|
||||
|
||||
-- Additional powerful text object for vim, this plugin should be studied
|
||||
-- carefully to use its full power
|
||||
@@ -383,9 +460,6 @@ local plugin_specs = {
|
||||
-- Plugin to manipulate character pairs quickly
|
||||
{ "machakann/vim-sandwich", event = "VeryLazy" },
|
||||
|
||||
-- Add indent object for vim (useful for languages like Python)
|
||||
{ "michaeljsmith/vim-indent-object", event = "VeryLazy" },
|
||||
|
||||
-- Only use these plugin on Windows and Mac and when LaTeX is installed
|
||||
{
|
||||
"lervag/vimtex",
|
||||
@@ -458,12 +532,6 @@ local plugin_specs = {
|
||||
cmd = { "OSCYank", "OSCYankReg" },
|
||||
},
|
||||
|
||||
-- The missing auto-completion for cmdline!
|
||||
{
|
||||
"gelguy/wilder.nvim",
|
||||
build = ":UpdateRemotePlugins",
|
||||
},
|
||||
|
||||
-- showing keybindings
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
@@ -495,8 +563,7 @@ local plugin_specs = {
|
||||
-- file explorer
|
||||
{
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
event = "VeryLazy",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
keys = { "<space>s" },
|
||||
config = function()
|
||||
require("config.nvim-tree")
|
||||
end,
|
||||
@@ -504,8 +571,7 @@ local plugin_specs = {
|
||||
|
||||
{
|
||||
"j-hui/fidget.nvim",
|
||||
event = "VeryLazy",
|
||||
tag = "legacy",
|
||||
event = "BufRead",
|
||||
config = function()
|
||||
require("config.fidget-nvim")
|
||||
end,
|
||||
@@ -525,13 +591,12 @@ local plugin_specs = {
|
||||
"CopilotC-Nvim/CopilotChat.nvim",
|
||||
dependencies = {
|
||||
{ "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
|
||||
{ "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
|
||||
},
|
||||
opts = {
|
||||
debug = true, -- Enable debugging
|
||||
-- See Configuration section for rest
|
||||
},
|
||||
-- See Commands section for default commands if you want to lazy load on them
|
||||
cmd = { "CopilotChat" },
|
||||
},
|
||||
{
|
||||
"zbirenbaum/copilot.lua",
|
||||
@@ -548,7 +613,6 @@ local plugin_specs = {
|
||||
config = function()
|
||||
require("config.live-command")
|
||||
end,
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
-- show hint for code actions, the user can also implement code actions themselves,
|
||||
@@ -557,9 +621,11 @@ local plugin_specs = {
|
||||
config = function()
|
||||
require("config.lightbulb")
|
||||
end,
|
||||
event = "LspAttach",
|
||||
},
|
||||
{
|
||||
"Bekaboo/dropbar.nvim",
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
"catgoose/nvim-colorizer.lua",
|
||||
|
||||
@@ -72,25 +72,6 @@ let g:neoformat_c_clangformat = {
|
||||
let g:neoformat_enabled_cpp = ['clangformat']
|
||||
let g:neoformat_enabled_c = ['clangformat']
|
||||
|
||||
"""""""""""""""""""""""""vim-markdown settings"""""""""""""""""""
|
||||
" Disable header folding
|
||||
let g:vim_markdown_folding_disabled = 1
|
||||
|
||||
" Whether to use conceal feature in markdown
|
||||
let g:vim_markdown_conceal = 1
|
||||
|
||||
" Disable math tex conceal and syntax highlight
|
||||
let g:tex_conceal = ''
|
||||
let g:vim_markdown_math = 0
|
||||
|
||||
" Support front matter of various format
|
||||
let g:vim_markdown_frontmatter = 1 " for YAML format
|
||||
let g:vim_markdown_toml_frontmatter = 1 " for TOML format
|
||||
let g:vim_markdown_json_frontmatter = 1 " for JSON format
|
||||
|
||||
" Let the TOC window autofit so that it doesn't take too much space
|
||||
let g:vim_markdown_toc_autofit = 1
|
||||
|
||||
"""""""""""""""""""""""""markdown-preview settings"""""""""""""""""""
|
||||
" Only setting this for suitable platforms
|
||||
if g:is_win || g:is_mac
|
||||
@@ -259,49 +240,3 @@ endif
|
||||
|
||||
""""""""""""""""""""""""""""""nvim-gdb settings""""""""""""""""""""""""""""""
|
||||
nnoremap <leader>dp :<C-U>GdbStartPDB python -m pdb %<CR>
|
||||
|
||||
""""""""""""""""""""""""""""""wilder.nvim settings""""""""""""""""""""""""""""""
|
||||
call timer_start(250, { -> s:wilder_init() })
|
||||
|
||||
function! s:wilder_init() abort
|
||||
try
|
||||
call wilder#setup({
|
||||
\ 'modes': [':', '/', '?'],
|
||||
\ 'next_key': '<Tab>',
|
||||
\ 'previous_key': '<S-Tab>',
|
||||
\ 'accept_key': '<C-y>',
|
||||
\ 'reject_key': '<C-e>'
|
||||
\ })
|
||||
|
||||
call wilder#set_option('pipeline', [
|
||||
\ wilder#branch(
|
||||
\ wilder#cmdline_pipeline({
|
||||
\ 'language': 'python',
|
||||
\ 'fuzzy': 1,
|
||||
\ 'sorter': wilder#python_difflib_sorter(),
|
||||
\ 'debounce': 30,
|
||||
\ }),
|
||||
\ wilder#python_search_pipeline({
|
||||
\ 'pattern': wilder#python_fuzzy_pattern(),
|
||||
\ 'sorter': wilder#python_difflib_sorter(),
|
||||
\ 'engine': 're',
|
||||
\ 'debounce': 30,
|
||||
\ }),
|
||||
\ ),
|
||||
\ ])
|
||||
|
||||
let l:hl = wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}])
|
||||
call wilder#set_option('renderer', wilder#popupmenu_renderer({
|
||||
\ 'highlighter': wilder#basic_highlighter(),
|
||||
\ 'max_height': 15,
|
||||
\ 'highlights': {
|
||||
\ 'accent': l:hl,
|
||||
\ },
|
||||
\ 'left': [' ', wilder#popupmenu_devicons(),],
|
||||
\ 'right': [' ', wilder#popupmenu_scrollbar(),],
|
||||
\ 'apply_incsearch_fix': 0,
|
||||
\ }))
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
echohl Error |echomsg "Wilder.nvim missing"| echohl None
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user