feat: add nvimdots
This commit is contained in:
80
nvim/lua/modules/configs/completion/aerial.lua
Normal file
80
nvim/lua/modules/configs/completion/aerial.lua
Normal file
@@ -0,0 +1,80 @@
|
||||
return function()
|
||||
require("modules.utils").load_plugin("aerial", {
|
||||
lazy_load = false,
|
||||
close_on_select = true,
|
||||
highlight_on_jump = false,
|
||||
disable_max_lines = 8500,
|
||||
disable_max_size = 1000000,
|
||||
ignore = { filetypes = { "NvimTree", "terminal", "nofile" } },
|
||||
-- Use symbol tree for folding. Set to true or false to enable/disable
|
||||
-- Set to "auto" to manage folds if your previous foldmethod was 'manual'
|
||||
-- This can be a filetype map (see :help aerial-filetype-map)
|
||||
manage_folds = "auto",
|
||||
layout = {
|
||||
-- Determines the default direction to open the aerial window. The 'prefer'
|
||||
-- options will open the window in the other direction *if* there is a
|
||||
-- different buffer in the way of the preferred direction
|
||||
-- Enum: prefer_right, prefer_left, right, left, float
|
||||
default_direction = "prefer_right",
|
||||
},
|
||||
-- Keymaps in aerial window. Can be any value that `vim.keymap.set` accepts OR a table of keymap
|
||||
-- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true })
|
||||
-- Additionally, if it is a string that matches "actions.<name>",
|
||||
-- it will use the mapping at require("aerial.actions").<name>
|
||||
-- Set to `false` to remove a keymap
|
||||
keymaps = {
|
||||
["?"] = "actions.show_help",
|
||||
["g?"] = "actions.show_help",
|
||||
["<CR>"] = "actions.jump",
|
||||
["<2-LeftMouse>"] = "actions.jump",
|
||||
["<C-v>"] = "actions.jump_vsplit",
|
||||
["<C-s>"] = "actions.jump_split",
|
||||
["<C-d>"] = "actions.down_and_scroll",
|
||||
["<C-u>"] = "actions.up_and_scroll",
|
||||
["{"] = "actions.prev",
|
||||
["}"] = "actions.next",
|
||||
["[["] = "actions.prev_up",
|
||||
["]]"] = "actions.next_up",
|
||||
["q"] = "actions.close",
|
||||
["o"] = "actions.tree_toggle",
|
||||
["O"] = "actions.tree_toggle_recursive",
|
||||
["zr"] = "actions.tree_increase_fold_level",
|
||||
["zR"] = "actions.tree_open_all",
|
||||
["zm"] = "actions.tree_decrease_fold_level",
|
||||
["zM"] = "actions.tree_close_all",
|
||||
["zx"] = "actions.tree_sync_folds",
|
||||
["zX"] = "actions.tree_sync_folds",
|
||||
},
|
||||
-- A list of all symbols to display. Set to false to display all symbols.
|
||||
-- This can be a filetype map (see :help aerial-filetype-map)
|
||||
-- To see all available values, see :help SymbolKind
|
||||
filter_kind = {
|
||||
"Array",
|
||||
"Boolean",
|
||||
"Class",
|
||||
"Constant",
|
||||
"Constructor",
|
||||
"Enum",
|
||||
"EnumMember",
|
||||
"Event",
|
||||
"Field",
|
||||
"File",
|
||||
"Function",
|
||||
"Interface",
|
||||
"Key",
|
||||
"Method",
|
||||
"Module",
|
||||
"Namespace",
|
||||
"Null",
|
||||
-- "Number",
|
||||
"Object",
|
||||
"Operator",
|
||||
"Package",
|
||||
-- "Property",
|
||||
-- "String",
|
||||
"Struct",
|
||||
-- "TypeParameter",
|
||||
-- "Variable",
|
||||
},
|
||||
})
|
||||
end
|
||||
199
nvim/lua/modules/configs/completion/cmp.lua
Normal file
199
nvim/lua/modules/configs/completion/cmp.lua
Normal file
@@ -0,0 +1,199 @@
|
||||
return function()
|
||||
local icons = {
|
||||
kind = require("modules.utils.icons").get("kind"),
|
||||
type = require("modules.utils.icons").get("type"),
|
||||
cmp = require("modules.utils.icons").get("cmp"),
|
||||
}
|
||||
|
||||
local border = function(hl)
|
||||
return {
|
||||
{ "┌", hl },
|
||||
{ "─", hl },
|
||||
{ "┐", hl },
|
||||
{ "│", hl },
|
||||
{ "┘", hl },
|
||||
{ "─", hl },
|
||||
{ "└", hl },
|
||||
{ "│", hl },
|
||||
}
|
||||
end
|
||||
|
||||
local compare = require("cmp.config.compare")
|
||||
compare.lsp_scores = function(entry1, entry2)
|
||||
local diff
|
||||
if entry1.completion_item.score and entry2.completion_item.score then
|
||||
diff = (entry2.completion_item.score * entry2.score) - (entry1.completion_item.score * entry1.score)
|
||||
else
|
||||
diff = entry2.score - entry1.score
|
||||
end
|
||||
return (diff < 0)
|
||||
end
|
||||
|
||||
local use_copilot = require("core.settings").use_copilot
|
||||
local comparators = use_copilot == true
|
||||
and {
|
||||
require("copilot_cmp.comparators").prioritize,
|
||||
require("copilot_cmp.comparators").score,
|
||||
-- require("cmp_tabnine.compare"),
|
||||
compare.offset, -- Items closer to cursor will have lower priority
|
||||
compare.exact,
|
||||
-- compare.scopes,
|
||||
compare.lsp_scores,
|
||||
compare.sort_text,
|
||||
compare.score,
|
||||
compare.recently_used,
|
||||
-- compare.locality, -- Items closer to cursor will have higher priority, conflicts with `offset`
|
||||
require("cmp-under-comparator").under,
|
||||
compare.kind,
|
||||
compare.length,
|
||||
compare.order,
|
||||
}
|
||||
or {
|
||||
-- require("cmp_tabnine.compare"),
|
||||
compare.offset, -- Items closer to cursor will have lower priority
|
||||
compare.exact,
|
||||
-- compare.scopes,
|
||||
compare.lsp_scores,
|
||||
compare.sort_text,
|
||||
compare.score,
|
||||
compare.recently_used,
|
||||
-- compare.locality, -- Items closer to cursor will have higher priority, conflicts with `offset`
|
||||
require("cmp-under-comparator").under,
|
||||
compare.kind,
|
||||
compare.length,
|
||||
compare.order,
|
||||
}
|
||||
|
||||
local cmp = require("cmp")
|
||||
require("modules.utils").load_plugin("cmp", {
|
||||
preselect = cmp.PreselectMode.None,
|
||||
window = {
|
||||
completion = {
|
||||
border = border("PmenuBorder"),
|
||||
winhighlight = "Normal:Pmenu,CursorLine:PmenuSel,Search:PmenuSel",
|
||||
scrollbar = false,
|
||||
},
|
||||
documentation = {
|
||||
border = border("CmpDocBorder"),
|
||||
winhighlight = "Normal:CmpDoc",
|
||||
},
|
||||
},
|
||||
sorting = {
|
||||
priority_weight = 2,
|
||||
comparators = comparators,
|
||||
},
|
||||
formatting = {
|
||||
fields = { "abbr", "kind", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
local lspkind_icons = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp)
|
||||
-- load lspkind icons
|
||||
vim_item.kind =
|
||||
string.format(" %s %s", lspkind_icons[vim_item.kind] or icons.cmp.undefined, vim_item.kind or "")
|
||||
|
||||
vim_item.menu = setmetatable({
|
||||
cmp_tabnine = "[TN]",
|
||||
copilot = "[CPLT]",
|
||||
buffer = "[BUF]",
|
||||
orgmode = "[ORG]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[LUA]",
|
||||
path = "[PATH]",
|
||||
tmux = "[TMUX]",
|
||||
treesitter = "[TS]",
|
||||
latex_symbols = "[LTEX]",
|
||||
luasnip = "[SNIP]",
|
||||
spell = "[SPELL]",
|
||||
}, {
|
||||
__index = function()
|
||||
return "[BTN]" -- builtin/unknown source names
|
||||
end,
|
||||
})[entry.source.name]
|
||||
|
||||
local label = vim_item.abbr
|
||||
local truncated_label = vim.fn.strcharpart(label, 0, 80)
|
||||
if truncated_label ~= label then
|
||||
vim_item.abbr = truncated_label .. "..."
|
||||
end
|
||||
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
matching = {
|
||||
disallow_partial_fuzzy_matching = false,
|
||||
},
|
||||
performance = {
|
||||
async_budget = 1,
|
||||
max_view_entries = 120,
|
||||
},
|
||||
-- You can set mappings if you want
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-w>"] = cmp.mapping.abort(),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||
elseif require("luasnip").expand_or_locally_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
|
||||
elseif require("luasnip").jumpable(-1) then
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<CR>"] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() and cmp.get_active_entry() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
s = cmp.mapping.confirm({ select = true }),
|
||||
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
|
||||
}),
|
||||
}),
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
-- You should specify your *installed* sources.
|
||||
sources = {
|
||||
{ name = "nvim_lsp", max_item_count = 350 },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "path" },
|
||||
{ name = "treesitter" },
|
||||
{ name = "spell" },
|
||||
{ name = "tmux" },
|
||||
{ name = "orgmode" },
|
||||
{
|
||||
name = "buffer",
|
||||
option = {
|
||||
get_bufnrs = function()
|
||||
return vim.api.nvim_buf_line_count(0) < 7500 and vim.api.nvim_list_bufs() or {}
|
||||
end,
|
||||
},
|
||||
},
|
||||
{ name = "latex_symbols" },
|
||||
{ name = "copilot" },
|
||||
-- { name = "codeium" },
|
||||
-- { name = "cmp_tabnine" },
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = {
|
||||
hl_group = "Whitespace",
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
3
nvim/lua/modules/configs/completion/codeium.lua
Normal file
3
nvim/lua/modules/configs/completion/codeium.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
return function()
|
||||
require("modules.utils").load_plugin("codeium", {})
|
||||
end
|
||||
3
nvim/lua/modules/configs/completion/copilot-cmp.lua
Normal file
3
nvim/lua/modules/configs/completion/copilot-cmp.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
return function()
|
||||
require("modules.utils").load_plugin("copilot_cmp", {})
|
||||
end
|
||||
28
nvim/lua/modules/configs/completion/copilot.lua
Normal file
28
nvim/lua/modules/configs/completion/copilot.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
return function()
|
||||
vim.defer_fn(function()
|
||||
require("modules.utils").load_plugin("copilot", {
|
||||
cmp = {
|
||||
enabled = true,
|
||||
method = "getCompletionsCycling",
|
||||
},
|
||||
panel = {
|
||||
-- if true, it can interfere with completions in copilot-cmp
|
||||
enabled = false,
|
||||
},
|
||||
suggestion = {
|
||||
-- if true, it can interfere with completions in copilot-cmp
|
||||
enabled = false,
|
||||
},
|
||||
filetypes = {
|
||||
["bigfile"] = false,
|
||||
["dap-repl"] = false,
|
||||
["fugitive"] = false,
|
||||
["fugitiveblame"] = false,
|
||||
["git"] = false,
|
||||
["gitcommit"] = false,
|
||||
["log"] = false,
|
||||
["toggleterm"] = false,
|
||||
},
|
||||
})
|
||||
end, 100)
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
return { "-style={BasedOnStyle: LLVM, IndentWidth: 4}" }
|
||||
198
nvim/lua/modules/configs/completion/formatting.lua
Normal file
198
nvim/lua/modules/configs/completion/formatting.lua
Normal file
@@ -0,0 +1,198 @@
|
||||
local M = {}
|
||||
|
||||
local settings = require("core.settings")
|
||||
local disabled_workspaces = settings.format_disabled_dirs
|
||||
local format_on_save = settings.format_on_save
|
||||
local format_notify = settings.format_notify
|
||||
local format_modifications_only = settings.format_modifications_only
|
||||
local server_formatting_block_list = settings.server_formatting_block_list
|
||||
local format_timeout = settings.format_timeout
|
||||
|
||||
vim.api.nvim_create_user_command("FormatToggle", function()
|
||||
M.toggle_format_on_save()
|
||||
end, {})
|
||||
|
||||
local block_list = settings.formatter_block_list
|
||||
vim.api.nvim_create_user_command("FormatterToggleFt", function(opts)
|
||||
if block_list[opts.args] == nil then
|
||||
vim.notify(
|
||||
string.format("[LSP] Formatter for [%s] has been recorded in list and disabled.", opts.args),
|
||||
vim.log.levels.WARN,
|
||||
{ title = "LSP Formatter Warning" }
|
||||
)
|
||||
block_list[opts.args] = true
|
||||
else
|
||||
block_list[opts.args] = not block_list[opts.args]
|
||||
vim.notify(
|
||||
string.format(
|
||||
"[LSP] Formatter for [%s] has been %s.",
|
||||
opts.args,
|
||||
not block_list[opts.args] and "enabled" or "disabled"
|
||||
),
|
||||
not block_list[opts.args] and vim.log.levels.INFO or vim.log.levels.WARN,
|
||||
{ title = string.format("LSP Formatter %s", not block_list[opts.args] and "Info" or "Warning") }
|
||||
)
|
||||
end
|
||||
end, { nargs = 1, complete = "filetype" })
|
||||
|
||||
function M.enable_format_on_save(is_configured)
|
||||
local opts = { pattern = "*", timeout = format_timeout }
|
||||
vim.api.nvim_create_augroup("format_on_save", { clear = true })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = "format_on_save",
|
||||
pattern = opts.pattern,
|
||||
callback = function()
|
||||
require("completion.formatting").format({
|
||||
timeout_ms = opts.timeout,
|
||||
filter = M.format_filter,
|
||||
})
|
||||
end,
|
||||
})
|
||||
if not is_configured then
|
||||
vim.notify(
|
||||
"Successfully enabled format-on-save",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Settings modification success" }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function M.disable_format_on_save(is_configured)
|
||||
pcall(vim.api.nvim_del_augroup_by_name, "format_on_save")
|
||||
if not is_configured then
|
||||
vim.notify(
|
||||
"Successfully disabled format-on-save",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Settings modification success" }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function M.configure_format_on_save()
|
||||
if format_on_save then
|
||||
M.enable_format_on_save(true)
|
||||
else
|
||||
M.disable_format_on_save(true)
|
||||
end
|
||||
end
|
||||
|
||||
function M.toggle_format_on_save()
|
||||
local status = pcall(vim.api.nvim_get_autocmds, {
|
||||
group = "format_on_save",
|
||||
event = "BufWritePre",
|
||||
})
|
||||
if not status then
|
||||
M.enable_format_on_save(false)
|
||||
else
|
||||
M.disable_format_on_save(false)
|
||||
end
|
||||
end
|
||||
|
||||
function M.format_filter(clients)
|
||||
return vim.tbl_filter(function(client)
|
||||
local status_ok, formatting_supported = pcall(function()
|
||||
return client.supports_method("textDocument/formatting")
|
||||
end)
|
||||
if status_ok and formatting_supported and client.name == "null-ls" then
|
||||
return "null-ls"
|
||||
elseif not server_formatting_block_list[client.name] and status_ok and formatting_supported then
|
||||
return client.name
|
||||
end
|
||||
end, clients)
|
||||
end
|
||||
|
||||
function M.format(opts)
|
||||
local filedir = vim.fn.expand("%:p:h")
|
||||
for i = 1, #disabled_workspaces do
|
||||
if vim.regex(vim.fs.normalize(disabled_workspaces[i])):match_str(filedir) ~= nil then
|
||||
vim.notify(
|
||||
string.format(
|
||||
"[LSP] Formatting for all files under [%s] has been disabled.",
|
||||
vim.fs.normalize(disabled_workspaces[i])
|
||||
),
|
||||
vim.log.levels.WARN,
|
||||
{ title = "LSP Formatter Warning" }
|
||||
)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local bufnr = opts.bufnr or vim.api.nvim_get_current_buf()
|
||||
local clients = vim.lsp.get_clients({ buffer = bufnr })
|
||||
|
||||
if opts.filter then
|
||||
clients = opts.filter(clients)
|
||||
elseif opts.id then
|
||||
clients = vim.tbl_filter(function(client)
|
||||
return client.id == opts.id
|
||||
end, clients)
|
||||
elseif opts.name then
|
||||
clients = vim.tbl_filter(function(client)
|
||||
return client.name == opts.name
|
||||
end, clients)
|
||||
end
|
||||
|
||||
clients = vim.tbl_filter(function(client)
|
||||
return client.supports_method("textDocument/formatting")
|
||||
end, clients)
|
||||
|
||||
if #clients == 0 then
|
||||
vim.notify(
|
||||
"[LSP] Format request failed, no matching language servers.",
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Formatting Failed" }
|
||||
)
|
||||
end
|
||||
|
||||
local timeout_ms = opts.timeout_ms
|
||||
for _, client in pairs(clients) do
|
||||
if block_list[vim.bo.filetype] == true then
|
||||
vim.notify(
|
||||
string.format(
|
||||
"[LSP][%s] Formatting for [%s] has been disabled. This file is not being processed.",
|
||||
client.name,
|
||||
vim.bo.filetype
|
||||
),
|
||||
vim.log.levels.WARN,
|
||||
{ title = "LSP Formatter Warning" }
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
if
|
||||
format_modifications_only
|
||||
and require("lsp-format-modifications").format_modifications(client, bufnr).success
|
||||
then
|
||||
if format_notify then
|
||||
vim.notify(
|
||||
string.format("[LSP] Format changed lines successfully with %s!", client.name),
|
||||
vim.log.levels.INFO,
|
||||
{ title = "LSP Range Format Success" }
|
||||
)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- Fall back to format the whole buffer (even if partial formatting failed)
|
||||
local params = vim.lsp.util.make_formatting_params(opts.formatting_options)
|
||||
local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, bufnr)
|
||||
if result and result.result then
|
||||
vim.lsp.util.apply_text_edits(result.result, bufnr, client.offset_encoding)
|
||||
if format_notify then
|
||||
vim.notify(
|
||||
string.format("[LSP] Format successfully with %s!", client.name),
|
||||
vim.log.levels.INFO,
|
||||
{ title = "LSP Format Success" }
|
||||
)
|
||||
end
|
||||
elseif err then
|
||||
vim.notify(
|
||||
string.format("[LSP][%s] %s", client.name, err),
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "LSP Format Error" }
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
83
nvim/lua/modules/configs/completion/glance.lua
Normal file
83
nvim/lua/modules/configs/completion/glance.lua
Normal file
@@ -0,0 +1,83 @@
|
||||
return function()
|
||||
local icons = { ui = require("modules.utils.icons").get("ui", true) }
|
||||
local actions = require("glance").actions
|
||||
|
||||
require("modules.utils").load_plugin("glance", {
|
||||
height = 20,
|
||||
zindex = 50,
|
||||
preview_win_opts = {
|
||||
cursorline = true,
|
||||
number = true,
|
||||
wrap = true,
|
||||
},
|
||||
border = {
|
||||
enable = require("core.settings").transparent_background,
|
||||
top_char = "―",
|
||||
bottom_char = "―",
|
||||
},
|
||||
list = {
|
||||
position = "right",
|
||||
width = 0.33, -- 33% width relative to the active window, min 0.1, max 0.5
|
||||
},
|
||||
folds = {
|
||||
folded = true, -- Automatically fold list on startup
|
||||
fold_closed = icons.ui.ArrowClosed,
|
||||
fold_open = icons.ui.ArrowOpen,
|
||||
},
|
||||
indent_lines = { enable = true },
|
||||
winbar = { enable = true },
|
||||
mappings = {
|
||||
list = {
|
||||
["k"] = actions.previous,
|
||||
["j"] = actions.next,
|
||||
["<Up>"] = actions.previous,
|
||||
["<Down>"] = actions.next,
|
||||
["<S-Tab>"] = actions.previous_location, -- Bring the cursor to the previous location skipping groups in the list
|
||||
["<Tab>"] = actions.next_location, -- Bring the cursor to the next location skipping groups in the list
|
||||
["<C-u>"] = actions.preview_scroll_win(8),
|
||||
["<C-d>"] = actions.preview_scroll_win(-8),
|
||||
["<CR>"] = actions.jump,
|
||||
["v"] = actions.jump_vsplit,
|
||||
["s"] = actions.jump_split,
|
||||
["t"] = actions.jump_tab,
|
||||
["c"] = actions.close_fold,
|
||||
["o"] = actions.open_fold,
|
||||
["[]"] = actions.enter_win("preview"), -- Focus preview window
|
||||
["q"] = actions.close,
|
||||
["Q"] = actions.close,
|
||||
["<Esc>"] = actions.close,
|
||||
["gq"] = actions.quickfix,
|
||||
},
|
||||
preview = {
|
||||
["Q"] = actions.close,
|
||||
["<C-c>q"] = actions.close,
|
||||
["<C-c>o"] = actions.jump,
|
||||
["<C-c>v"] = actions.jump_vsplit,
|
||||
["<C-c>s"] = actions.jump_split,
|
||||
["<C-c>t"] = actions.jump_tab,
|
||||
["<C-p>"] = actions.previous_location,
|
||||
["<C-n>"] = actions.next_location,
|
||||
["[]"] = actions.enter_win("list"), -- Focus list window
|
||||
},
|
||||
},
|
||||
hooks = {
|
||||
before_open = function(results, open, _, method)
|
||||
if #results == 0 then
|
||||
vim.notify(
|
||||
"This method is not supported by any of the servers registered for the current buffer",
|
||||
vim.log.levels.WARN,
|
||||
{ title = "Glance" }
|
||||
)
|
||||
elseif #results == 1 and method == "references" then
|
||||
vim.notify(
|
||||
"The identifier under cursor is the only one found",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Glance" }
|
||||
)
|
||||
else
|
||||
open(results)
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
15
nvim/lua/modules/configs/completion/lsp-signature.lua
Normal file
15
nvim/lua/modules/configs/completion/lsp-signature.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
return function()
|
||||
require("modules.utils").load_plugin("lsp_signature", {
|
||||
bind = true,
|
||||
-- TODO: Remove the following line when nvim-cmp#1613 gets resolved
|
||||
check_completion_visible = false,
|
||||
floating_window = true,
|
||||
floating_window_above_cur_line = true,
|
||||
hi_parameter = "Search",
|
||||
hint_enable = true,
|
||||
transparency = nil, -- disabled by default, allow floating win transparent value 1~100
|
||||
wrap = true,
|
||||
zindex = 45, -- avoid overlap with nvim.cmp
|
||||
handler_opts = { border = "single" },
|
||||
})
|
||||
end
|
||||
23
nvim/lua/modules/configs/completion/lsp.lua
Normal file
23
nvim/lua/modules/configs/completion/lsp.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
return function()
|
||||
local nvim_lsp = require("lspconfig")
|
||||
require("completion.neoconf").setup()
|
||||
require("completion.mason").setup()
|
||||
require("completion.mason-lspconfig").setup()
|
||||
|
||||
local opts = {
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
}
|
||||
-- Setup lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here.
|
||||
if vim.fn.executable("dart") == 1 then
|
||||
local ok, _opts = pcall(require, "user.configs.lsp-servers.dartls")
|
||||
if not ok then
|
||||
_opts = require("completion.servers.dartls")
|
||||
end
|
||||
local final_opts = vim.tbl_deep_extend("keep", _opts, opts)
|
||||
nvim_lsp.dartls.setup(final_opts)
|
||||
end
|
||||
|
||||
pcall(require, "user.configs.lsp")
|
||||
|
||||
pcall(vim.cmd.LspStart) -- Start LSPs
|
||||
end
|
||||
183
nvim/lua/modules/configs/completion/lspsaga.lua
Normal file
183
nvim/lua/modules/configs/completion/lspsaga.lua
Normal file
@@ -0,0 +1,183 @@
|
||||
return function()
|
||||
require("modules.utils").gen_lspkind_hl()
|
||||
|
||||
local icons = {
|
||||
cmp = require("modules.utils.icons").get("cmp", true),
|
||||
diagnostics = require("modules.utils.icons").get("diagnostics", true),
|
||||
kind = require("modules.utils.icons").get("kind", true),
|
||||
type = require("modules.utils.icons").get("type", true),
|
||||
ui = require("modules.utils.icons").get("ui", true),
|
||||
}
|
||||
|
||||
local function set_sidebar_icons()
|
||||
-- Set icons for sidebar
|
||||
vim.diagnostic.config({
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = icons.diagnostics.Error_alt,
|
||||
[vim.diagnostic.severity.WARN] = icons.diagnostics.Warning_alt,
|
||||
[vim.diagnostic.severity.INFO] = icons.diagnostics.Information_alt,
|
||||
[vim.diagnostic.severity.HINT] = icons.diagnostics.Hint_alt,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
set_sidebar_icons()
|
||||
|
||||
require("modules.utils").load_plugin("lspsaga", {
|
||||
-- Breadcrumbs: https://nvimdev.github.io/lspsaga/breadcrumbs/
|
||||
symbol_in_winbar = {
|
||||
enable = false,
|
||||
separator = " " .. icons.ui.Separator,
|
||||
hide_keyword = false,
|
||||
show_file = false,
|
||||
folder_level = 1,
|
||||
color_mode = true,
|
||||
delay = 100,
|
||||
},
|
||||
-- Callhierarchy: https://nvimdev.github.io/lspsaga/callhierarchy/
|
||||
callhierarchy = {
|
||||
layout = "float",
|
||||
keys = {
|
||||
edit = "e",
|
||||
vsplit = "v",
|
||||
split = "s",
|
||||
tabe = "t",
|
||||
quit = "q",
|
||||
shuttle = "[]",
|
||||
toggle_or_req = "u",
|
||||
close = "<Esc>",
|
||||
},
|
||||
},
|
||||
-- Code Action: https://nvimdev.github.io/lspsaga/codeaction/
|
||||
code_action = {
|
||||
num_shortcut = true,
|
||||
only_in_cursor = false,
|
||||
show_server_name = true,
|
||||
extend_gitsigns = false,
|
||||
keys = {
|
||||
quit = "q",
|
||||
exec = "<CR>",
|
||||
},
|
||||
},
|
||||
-- Diagnostics: https://nvimdev.github.io/lspsaga/diagnostic/
|
||||
diagnostic = {
|
||||
show_code_action = true,
|
||||
jump_num_shortcut = true,
|
||||
max_width = 0.5,
|
||||
max_height = 0.6,
|
||||
text_hl_follow = true,
|
||||
border_follow = true,
|
||||
extend_relatedInformation = true,
|
||||
show_layout = "float",
|
||||
show_normal_height = 10,
|
||||
max_show_width = 0.9,
|
||||
max_show_height = 0.6,
|
||||
diagnostic_only_current = false,
|
||||
keys = {
|
||||
exec_action = "r",
|
||||
quit = "q",
|
||||
toggle_or_jump = "<CR>",
|
||||
quit_in_show = { "q", "<Esc>" },
|
||||
},
|
||||
},
|
||||
-- Hover: https://nvimdev.github.io/lspsaga/hover/
|
||||
hover = {
|
||||
max_width = 0.45,
|
||||
max_height = 0.7,
|
||||
open_link = "gl",
|
||||
open_cmd = "silent !" .. require("core.settings").external_browser,
|
||||
},
|
||||
-- Impl: https://nvimdev.github.io/lspsaga/implement/
|
||||
implement = {
|
||||
enable = true,
|
||||
sign = true,
|
||||
virtual_text = false,
|
||||
priority = 100,
|
||||
},
|
||||
-- LightBulb: https://nvimdev.github.io/lspsaga/lightbulb/
|
||||
lightbulb = {
|
||||
enable = false,
|
||||
sign = true,
|
||||
virtual_text = false,
|
||||
debounce = 10,
|
||||
sign_priority = 20,
|
||||
},
|
||||
-- Rename: https://nvimdev.github.io/lspsaga/rename/
|
||||
rename = {
|
||||
in_select = false,
|
||||
auto_save = false,
|
||||
project_max_width = 0.5,
|
||||
project_max_height = 0.5,
|
||||
keys = {
|
||||
quit = "<C-c>",
|
||||
exec = "<CR>",
|
||||
select = "x",
|
||||
},
|
||||
},
|
||||
-- Beacon: https://nvimdev.github.io/lspsaga/misc/#beacon
|
||||
beacon = {
|
||||
enable = true,
|
||||
frequency = 12,
|
||||
},
|
||||
-- Generic UI Options: https://nvimdev.github.io/lspsaga/misc/#generic-ui-options
|
||||
ui = {
|
||||
border = "single", -- Can be single, double, rounded, solid, shadow.
|
||||
devicon = true,
|
||||
title = true,
|
||||
expand = icons.ui.ArrowClosed,
|
||||
collapse = icons.ui.ArrowOpen,
|
||||
code_action = icons.ui.CodeAction,
|
||||
actionfix = icons.ui.Spell,
|
||||
lines = { "┗", "┣", "┃", "━", "┏" },
|
||||
imp_sign = icons.kind.Implementation,
|
||||
kind = {
|
||||
-- Kind
|
||||
Class = { icons.kind.Class, "LspKindClass" },
|
||||
Constant = { icons.kind.Constant, "LspKindConstant" },
|
||||
Constructor = { icons.kind.Constructor, "LspKindConstructor" },
|
||||
Enum = { icons.kind.Enum, "LspKindEnum" },
|
||||
EnumMember = { icons.kind.EnumMember, "LspKindEnumMember" },
|
||||
Event = { icons.kind.Event, "LspKindEvent" },
|
||||
Field = { icons.kind.Field, "LspKindField" },
|
||||
File = { icons.kind.File, "LspKindFile" },
|
||||
Function = { icons.kind.Function, "LspKindFunction" },
|
||||
Interface = { icons.kind.Interface, "LspKindInterface" },
|
||||
Key = { icons.kind.Keyword, "LspKindKey" },
|
||||
Method = { icons.kind.Method, "LspKindMethod" },
|
||||
Module = { icons.kind.Module, "LspKindModule" },
|
||||
Namespace = { icons.kind.Namespace, "LspKindNamespace" },
|
||||
Operator = { icons.kind.Operator, "LspKindOperator" },
|
||||
Package = { icons.kind.Package, "LspKindPackage" },
|
||||
Property = { icons.kind.Property, "LspKindProperty" },
|
||||
Struct = { icons.kind.Struct, "LspKindStruct" },
|
||||
TypeParameter = { icons.kind.TypeParameter, "LspKindTypeParameter" },
|
||||
Variable = { icons.kind.Variable, "LspKindVariable" },
|
||||
-- Type
|
||||
Array = { icons.type.Array, "LspKindArray" },
|
||||
Boolean = { icons.type.Boolean, "LspKindBoolean" },
|
||||
Null = { icons.type.Null, "LspKindNull" },
|
||||
Number = { icons.type.Number, "LspKindNumber" },
|
||||
Object = { icons.type.Object, "LspKindObject" },
|
||||
String = { icons.type.String, "LspKindString" },
|
||||
-- ccls-specific icons.
|
||||
TypeAlias = { icons.kind.TypeAlias, "LspKindTypeAlias" },
|
||||
Parameter = { icons.kind.Parameter, "LspKindParameter" },
|
||||
StaticMethod = { icons.kind.StaticMethod, "LspKindStaticMethod" },
|
||||
-- Microsoft-specific icons.
|
||||
Text = { icons.kind.Text, "LspKindText" },
|
||||
Snippet = { icons.kind.Snippet, "LspKindSnippet" },
|
||||
Folder = { icons.kind.Folder, "LspKindFolder" },
|
||||
Unit = { icons.kind.Unit, "LspKindUnit" },
|
||||
Value = { icons.kind.Value, "LspKindValue" },
|
||||
},
|
||||
},
|
||||
-- Scrolling Keymaps: https://nvimdev.github.io/lspsaga/misc/#scrolling-keymaps
|
||||
scroll_preview = {
|
||||
scroll_down = "<C-d>",
|
||||
scroll_up = "<C-u>",
|
||||
},
|
||||
request_timeout = 3000,
|
||||
})
|
||||
end
|
||||
15
nvim/lua/modules/configs/completion/luasnip.lua
Normal file
15
nvim/lua/modules/configs/completion/luasnip.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
return function()
|
||||
local snippet_path = vim.fn.stdpath("config") .. "/snips/"
|
||||
if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then
|
||||
vim.opt.rtp:append(snippet_path)
|
||||
end
|
||||
|
||||
require("modules.utils").load_plugin("luasnip", {
|
||||
history = true,
|
||||
update_events = "TextChanged,TextChangedI",
|
||||
delete_check_events = "TextChanged,InsertLeave",
|
||||
}, false, require("luasnip").config.set_config)
|
||||
require("luasnip.loaders.from_lua").lazy_load()
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_snipmate").lazy_load()
|
||||
end
|
||||
86
nvim/lua/modules/configs/completion/mason-lspconfig.lua
Normal file
86
nvim/lua/modules/configs/completion/mason-lspconfig.lua
Normal file
@@ -0,0 +1,86 @@
|
||||
local M = {}
|
||||
|
||||
M.setup = function()
|
||||
local diagnostics_virtual_text = require("core.settings").diagnostics_virtual_text
|
||||
local diagnostics_level = require("core.settings").diagnostics_level
|
||||
|
||||
local nvim_lsp = require("lspconfig")
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
require("lspconfig.ui.windows").default_options.border = "rounded"
|
||||
|
||||
require("modules.utils").load_plugin("mason-lspconfig", {
|
||||
ensure_installed = require("core.settings").lsp_deps,
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
signs = true,
|
||||
underline = true,
|
||||
virtual_text = diagnostics_virtual_text and {
|
||||
severity = {
|
||||
min = vim.diagnostic.severity[diagnostics_level],
|
||||
},
|
||||
} or false,
|
||||
-- set update_in_insert to false because it was enabled by lspsaga
|
||||
update_in_insert = false,
|
||||
})
|
||||
|
||||
local opts = {
|
||||
capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
require("cmp_nvim_lsp").default_capabilities()
|
||||
),
|
||||
}
|
||||
---A handler to setup all servers defined under `completion/servers/*.lua`
|
||||
---@param lsp_name string
|
||||
local function mason_lsp_handler(lsp_name)
|
||||
-- rust_analyzer is configured using mrcjkb/rustaceanvim
|
||||
-- warn users if they have set it up manually
|
||||
if lsp_name == "rust_analyzer" then
|
||||
local config_exist = pcall(require, "completion.servers." .. lsp_name)
|
||||
if config_exist then
|
||||
vim.notify(
|
||||
[[
|
||||
`rust_analyzer` is configured independently via `mrcjkb/rustaceanvim`. To get rid of this warning,
|
||||
please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` directory and configure
|
||||
`rust_analyzer` using the appropriate init options provided by `rustaceanvim` instead.]],
|
||||
vim.log.levels.WARN,
|
||||
{ title = "nvim-lspconfig" }
|
||||
)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local ok, custom_handler = pcall(require, "user.configs.lsp-servers." .. lsp_name)
|
||||
-- Use preset if there is no user definition
|
||||
if not ok then
|
||||
ok, custom_handler = pcall(require, "completion.servers." .. lsp_name)
|
||||
end
|
||||
if not ok then
|
||||
-- Default to use factory config for server(s) that doesn't include a spec
|
||||
nvim_lsp[lsp_name].setup(opts)
|
||||
return
|
||||
elseif type(custom_handler) == "function" then
|
||||
--- Case where language server requires its own setup
|
||||
--- Make sure to call require("lspconfig")[lsp_name].setup() in the function
|
||||
--- See `clangd.lua` for example.
|
||||
custom_handler(opts)
|
||||
elseif type(custom_handler) == "table" then
|
||||
nvim_lsp[lsp_name].setup(vim.tbl_deep_extend("force", opts, custom_handler))
|
||||
else
|
||||
vim.notify(
|
||||
string.format(
|
||||
"Failed to setup [%s].\n\nServer definition under `completion/servers` must return\neither a fun(opts) or a table (got '%s' instead)",
|
||||
lsp_name,
|
||||
type(custom_handler)
|
||||
),
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "nvim-lspconfig" }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
mason_lspconfig.setup_handlers({ mason_lsp_handler })
|
||||
end
|
||||
|
||||
return M
|
||||
12
nvim/lua/modules/configs/completion/mason-null-ls.lua
Normal file
12
nvim/lua/modules/configs/completion/mason-null-ls.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local M = {}
|
||||
|
||||
M.setup = function()
|
||||
require("modules.utils").load_plugin("mason-null-ls", {
|
||||
ensure_installed = require("core.settings").null_ls_deps,
|
||||
automatic_installation = false,
|
||||
automatic_setup = true,
|
||||
handlers = {},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
94
nvim/lua/modules/configs/completion/mason.lua
Normal file
94
nvim/lua/modules/configs/completion/mason.lua
Normal file
@@ -0,0 +1,94 @@
|
||||
local M = {}
|
||||
|
||||
M.setup = function()
|
||||
local is_windows = require("core.global").is_windows
|
||||
|
||||
local mason_registry = require("mason-registry")
|
||||
require("lspconfig.ui.windows").default_options.border = "rounded"
|
||||
|
||||
local icons = {
|
||||
ui = require("modules.utils.icons").get("ui", true),
|
||||
misc = require("modules.utils.icons").get("misc", true),
|
||||
}
|
||||
|
||||
require("modules.utils").load_plugin("mason", {
|
||||
ui = {
|
||||
border = "single",
|
||||
icons = {
|
||||
package_pending = icons.ui.Modified_alt,
|
||||
package_installed = icons.ui.Check,
|
||||
package_uninstalled = icons.misc.Ghost,
|
||||
},
|
||||
keymaps = {
|
||||
toggle_server_expand = "<CR>",
|
||||
install_server = "i",
|
||||
update_server = "u",
|
||||
check_server_version = "c",
|
||||
update_all_servers = "U",
|
||||
check_outdated_servers = "C",
|
||||
uninstall_server = "X",
|
||||
cancel_installation = "<C-c>",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Additional plugins for pylsp
|
||||
mason_registry:on(
|
||||
"package:install:success",
|
||||
vim.schedule_wrap(function(pkg)
|
||||
if pkg.name ~= "python-lsp-server" then
|
||||
return
|
||||
end
|
||||
|
||||
local venv = vim.fn.stdpath("data") .. "/mason/packages/python-lsp-server/venv"
|
||||
local python = is_windows and venv .. "/Scripts/python.exe" or venv .. "/bin/python"
|
||||
local black = is_windows and venv .. "/Scripts/black.exe" or venv .. "/bin/black"
|
||||
local ruff = is_windows and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff"
|
||||
|
||||
require("plenary.job")
|
||||
:new({
|
||||
command = python,
|
||||
args = {
|
||||
"-m",
|
||||
"pip",
|
||||
"install",
|
||||
"-U",
|
||||
"--disable-pip-version-check",
|
||||
"python-lsp-black",
|
||||
"python-lsp-ruff",
|
||||
"pylsp-rope",
|
||||
},
|
||||
cwd = venv,
|
||||
env = { VIRTUAL_ENV = venv },
|
||||
on_exit = function()
|
||||
if vim.fn.executable(black) == 1 and vim.fn.executable(ruff) == 1 then
|
||||
vim.notify(
|
||||
"Finished installing pylsp plugins",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "[lsp] Install Status" }
|
||||
)
|
||||
else
|
||||
vim.notify(
|
||||
"Failed to install pylsp plugins. [Executable not found]",
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "[lsp] Install Failure" }
|
||||
)
|
||||
end
|
||||
end,
|
||||
on_start = function()
|
||||
vim.notify(
|
||||
"Now installing pylsp plugins...",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "[lsp] Install Status", timeout = 6000 }
|
||||
)
|
||||
end,
|
||||
on_stderr = function(_, msg_stream)
|
||||
vim.notify(msg_stream, vim.log.levels.ERROR, { title = "[lsp] Install Failure" })
|
||||
end,
|
||||
})
|
||||
:start()
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
return M
|
||||
20
nvim/lua/modules/configs/completion/neoconf.lua
Normal file
20
nvim/lua/modules/configs/completion/neoconf.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
local M = {}
|
||||
|
||||
M.setup = function()
|
||||
require("modules.utils").load_plugin("neoconf", {
|
||||
-- send new configuration to lsp clients when changing json settings
|
||||
live_reload = true,
|
||||
-- name of the local settings files
|
||||
local_settings = ".neoconf.json",
|
||||
-- name of the global settings file in your Neovim config directory
|
||||
global_settings = "neoconf.json",
|
||||
-- import existing settings from other plugins
|
||||
import = {
|
||||
vscode = true, -- local .vscode/settings.json
|
||||
coc = true, -- global/local coc-settings.json
|
||||
nlsp = true, -- global/local nlsp-settings.nvim json settings
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
77
nvim/lua/modules/configs/completion/null-ls.lua
Normal file
77
nvim/lua/modules/configs/completion/null-ls.lua
Normal file
@@ -0,0 +1,77 @@
|
||||
return function()
|
||||
local null_ls = require("null-ls")
|
||||
local btns = null_ls.builtins
|
||||
|
||||
---Return formatter args required by `extra_args`
|
||||
---@param formatter_name string
|
||||
---@return table|nil
|
||||
local function formatter_args(formatter_name)
|
||||
local ok, args = pcall(require, "user.configs.formatters." .. formatter_name)
|
||||
if not ok then
|
||||
args = require("completion.formatters." .. formatter_name)
|
||||
end
|
||||
return args
|
||||
end
|
||||
|
||||
-- Please set additional flags for the supported servers here
|
||||
-- Don't specify any config here if you are using the default one.
|
||||
local sources = {
|
||||
btns.formatting.clang_format.with({
|
||||
filetypes = { "c", "cpp", "objc", "objcpp", "cs", "java", "cuda", "proto" },
|
||||
extra_args = formatter_args("clang_format"),
|
||||
}),
|
||||
btns.formatting.prettier.with({
|
||||
filetypes = {
|
||||
"vue",
|
||||
"typescript",
|
||||
"javascript",
|
||||
"typescriptreact",
|
||||
"javascriptreact",
|
||||
"yaml",
|
||||
"html",
|
||||
"css",
|
||||
"scss",
|
||||
"sh",
|
||||
"markdown",
|
||||
},
|
||||
}),
|
||||
}
|
||||
require("modules.utils").load_plugin("null-ls", {
|
||||
border = "rounded",
|
||||
debug = false,
|
||||
log_level = "warn",
|
||||
update_in_insert = false,
|
||||
sources = sources,
|
||||
default_timeout = require("core.settings").format_timeout,
|
||||
})
|
||||
|
||||
require("completion.mason-null-ls").setup()
|
||||
|
||||
-- Setup usercmd to register/deregister available source(s)
|
||||
local function _gen_completion()
|
||||
local sources_cont = null_ls.get_source({
|
||||
filetype = vim.bo.filetype,
|
||||
})
|
||||
local completion_items = {}
|
||||
for _, server in pairs(sources_cont) do
|
||||
table.insert(completion_items, server.name)
|
||||
end
|
||||
return completion_items
|
||||
end
|
||||
vim.api.nvim_create_user_command("NullLsToggle", function(opts)
|
||||
if vim.tbl_contains(_gen_completion(), opts.args) then
|
||||
null_ls.toggle({ name = opts.args })
|
||||
else
|
||||
vim.notify(
|
||||
string.format("[Null-ls] Unable to find any registered source named [%s].", opts.args),
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "Null-ls Internal Error" }
|
||||
)
|
||||
end
|
||||
end, {
|
||||
nargs = 1,
|
||||
complete = _gen_completion,
|
||||
})
|
||||
|
||||
require("completion.formatting").configure_format_on_save()
|
||||
end
|
||||
5
nvim/lua/modules/configs/completion/servers/bashls.lua
Normal file
5
nvim/lua/modules/configs/completion/servers/bashls.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/bashls.lua
|
||||
return {
|
||||
cmd = { "bash-language-server", "start" },
|
||||
filetypes = { "bash", "sh" },
|
||||
}
|
||||
79
nvim/lua/modules/configs/completion/servers/clangd.lua
Normal file
79
nvim/lua/modules/configs/completion/servers/clangd.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
local function switch_source_header_splitcmd(bufnr, splitcmd)
|
||||
bufnr = require("lspconfig").util.validate_bufnr(bufnr)
|
||||
local clangd_client = require("lspconfig").util.get_active_client_by_name(bufnr, "clangd")
|
||||
local params = { uri = vim.uri_from_bufnr(bufnr) }
|
||||
if clangd_client then
|
||||
clangd_client.request("textDocument/switchSourceHeader", params, function(err, result)
|
||||
if err then
|
||||
error(tostring(err))
|
||||
end
|
||||
if not result then
|
||||
vim.notify("Corresponding file can’t be determined", vim.log.levels.ERROR, { title = "LSP Error!" })
|
||||
return
|
||||
end
|
||||
vim.api.nvim_command(splitcmd .. " " .. vim.uri_to_fname(result))
|
||||
end)
|
||||
else
|
||||
vim.notify(
|
||||
"Method textDocument/switchSourceHeader is not supported by any active server on this buffer",
|
||||
vim.log.levels.ERROR,
|
||||
{ title = "LSP Error!" }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_binary_path_list(binaries)
|
||||
local path_list = {}
|
||||
for _, binary in ipairs(binaries) do
|
||||
local path = vim.fn.exepath(binary)
|
||||
if path ~= "" then
|
||||
table.insert(path_list, path)
|
||||
end
|
||||
end
|
||||
return table.concat(path_list, ",")
|
||||
end
|
||||
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/clangd.lua
|
||||
return function(options)
|
||||
require("lspconfig").clangd.setup({
|
||||
on_attach = options.on_attach,
|
||||
capabilities = vim.tbl_deep_extend("keep", { offsetEncoding = { "utf-16", "utf-8" } }, options.capabilities),
|
||||
single_file_support = true,
|
||||
cmd = {
|
||||
"clangd",
|
||||
"-j=12",
|
||||
"--enable-config",
|
||||
"--background-index",
|
||||
"--pch-storage=memory",
|
||||
-- You MUST set this arg ↓ to your c/cpp compiler location (if not included)!
|
||||
"--query-driver=" .. get_binary_path_list({ "clang++", "clang", "gcc", "g++" }),
|
||||
"--clang-tidy",
|
||||
"--all-scopes-completion",
|
||||
"--completion-style=detailed",
|
||||
"--header-insertion-decorators",
|
||||
"--header-insertion=iwyu",
|
||||
"--limit-references=3000",
|
||||
"--limit-results=350",
|
||||
},
|
||||
commands = {
|
||||
ClangdSwitchSourceHeader = {
|
||||
function()
|
||||
switch_source_header_splitcmd(0, "edit")
|
||||
end,
|
||||
description = "Open source/header in current buffer",
|
||||
},
|
||||
ClangdSwitchSourceHeaderVSplit = {
|
||||
function()
|
||||
switch_source_header_splitcmd(0, "vsplit")
|
||||
end,
|
||||
description = "Open source/header in a new vsplit",
|
||||
},
|
||||
ClangdSwitchSourceHeaderSplit = {
|
||||
function()
|
||||
switch_source_header_splitcmd(0, "split")
|
||||
end,
|
||||
description = "Open source/header in a new split",
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
12
nvim/lua/modules/configs/completion/servers/dartls.lua
Normal file
12
nvim/lua/modules/configs/completion/servers/dartls.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/dartls.lua
|
||||
return {
|
||||
cmd = { "dart", "language-server", "--protocol=lsp" },
|
||||
filetypes = { "dart" },
|
||||
init_options = {
|
||||
closingLabels = true,
|
||||
flutterOutline = true,
|
||||
onlyAnalyzeProjectsWithOpenFiles = true,
|
||||
outline = true,
|
||||
suggestFromUnimportedLibraries = true,
|
||||
},
|
||||
}
|
||||
50
nvim/lua/modules/configs/completion/servers/gopls.lua
Normal file
50
nvim/lua/modules/configs/completion/servers/gopls.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/gopls.lua
|
||||
return {
|
||||
cmd = { "gopls", "-remote.debug=:0", "-remote=auto" },
|
||||
filetypes = { "go", "gomod", "gosum", "gotmpl", "gohtmltmpl", "gotexttmpl" },
|
||||
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
contextSupport = true,
|
||||
dynamicRegistration = true,
|
||||
completionItem = {
|
||||
commitCharactersSupport = true,
|
||||
deprecatedSupport = true,
|
||||
preselectSupport = true,
|
||||
insertReplaceSupport = true,
|
||||
labelDetailsSupport = true,
|
||||
snippetSupport = true,
|
||||
documentationFormat = { "markdown", "plaintext" },
|
||||
resolveSupport = {
|
||||
properties = {
|
||||
"documentation",
|
||||
"details",
|
||||
"additionalTextEdits",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
settings = {
|
||||
gopls = {
|
||||
staticcheck = true,
|
||||
semanticTokens = true,
|
||||
noSemanticString = true,
|
||||
usePlaceholders = true,
|
||||
completeUnimported = true,
|
||||
symbolMatcher = "Fuzzy",
|
||||
buildFlags = { "-tags", "integration" },
|
||||
codelenses = {
|
||||
generate = true,
|
||||
gc_details = true,
|
||||
test = true,
|
||||
tidy = true,
|
||||
vendor = true,
|
||||
regenerate_cgo = true,
|
||||
upgrade_dependency = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
12
nvim/lua/modules/configs/completion/servers/html.lua
Normal file
12
nvim/lua/modules/configs/completion/servers/html.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- https://github.com/vscode-langservers/vscode-html-languageserver-bin
|
||||
return {
|
||||
cmd = { "html-languageserver", "--stdio" },
|
||||
filetypes = { "html" },
|
||||
init_options = {
|
||||
configurationSection = { "html", "css", "javascript" },
|
||||
embeddedLanguages = { css = true, javascript = true },
|
||||
},
|
||||
settings = {},
|
||||
single_file_support = true,
|
||||
flags = { debounce_text_changes = 500 },
|
||||
}
|
||||
55
nvim/lua/modules/configs/completion/servers/jsonls.lua
Normal file
55
nvim/lua/modules/configs/completion/servers/jsonls.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/jsonls.lua
|
||||
return {
|
||||
flags = { debounce_text_changes = 500 },
|
||||
settings = {
|
||||
json = {
|
||||
-- Schemas https://www.schemastore.org
|
||||
schemas = {
|
||||
{
|
||||
fileMatch = { "package.json" },
|
||||
url = "https://json.schemastore.org/package.json",
|
||||
},
|
||||
{
|
||||
fileMatch = { "tsconfig*.json" },
|
||||
url = "https://json.schemastore.org/tsconfig.json",
|
||||
},
|
||||
{
|
||||
fileMatch = {
|
||||
".prettierrc",
|
||||
".prettierrc.json",
|
||||
"prettier.config.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/prettierrc.json",
|
||||
},
|
||||
{
|
||||
fileMatch = { ".eslintrc", ".eslintrc.json" },
|
||||
url = "https://json.schemastore.org/eslintrc.json",
|
||||
},
|
||||
{
|
||||
fileMatch = {
|
||||
".babelrc",
|
||||
".babelrc.json",
|
||||
"babel.config.json",
|
||||
},
|
||||
url = "https://json.schemastore.org/babelrc.json",
|
||||
},
|
||||
{
|
||||
fileMatch = { "lerna.json" },
|
||||
url = "https://json.schemastore.org/lerna.json",
|
||||
},
|
||||
{
|
||||
fileMatch = {
|
||||
".stylelintrc",
|
||||
".stylelintrc.json",
|
||||
"stylelint.config.json",
|
||||
},
|
||||
url = "http://json.schemastore.org/stylelintrc.json",
|
||||
},
|
||||
{
|
||||
fileMatch = { "/.github/workflows/*" },
|
||||
url = "https://json.schemastore.org/github-workflow.json",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
25
nvim/lua/modules/configs/completion/servers/lua_ls.lua
Normal file
25
nvim/lua/modules/configs/completion/servers/lua_ls.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/lua_ls.lua
|
||||
return {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = { version = "LuaJIT" },
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
disable = { "different-requires", "undefined-field" },
|
||||
},
|
||||
workspace = {
|
||||
library = {
|
||||
vim.fn.expand("$VIMRUNTIME/lua"),
|
||||
vim.fn.expand("$VIMRUNTIME/lua/vim/lsp"),
|
||||
},
|
||||
maxPreload = 100000,
|
||||
preloadFileSize = 10000,
|
||||
},
|
||||
hint = { enable = true, setType = true },
|
||||
format = { enable = false },
|
||||
telemetry = { enable = false },
|
||||
-- Do not override treesitter lua highlighting with lua_ls's highlighting
|
||||
semantic = { enable = false },
|
||||
},
|
||||
},
|
||||
}
|
||||
46
nvim/lua/modules/configs/completion/servers/pylsp.lua
Normal file
46
nvim/lua/modules/configs/completion/servers/pylsp.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/pylsp.lua
|
||||
return {
|
||||
cmd = { "pylsp" },
|
||||
filetypes = { "python" },
|
||||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
-- Lint
|
||||
ruff = {
|
||||
enabled = true,
|
||||
select = {
|
||||
-- enable pycodestyle
|
||||
"E",
|
||||
-- enable pyflakes
|
||||
"F",
|
||||
},
|
||||
ignore = {
|
||||
-- ignore E501 (line too long)
|
||||
-- "E501",
|
||||
-- ignore F401 (imported but unused)
|
||||
-- "F401",
|
||||
},
|
||||
extendSelect = { "I" },
|
||||
severities = {
|
||||
-- Hint, Information, Warning, Error
|
||||
F401 = "I",
|
||||
E501 = "I",
|
||||
},
|
||||
},
|
||||
flake8 = { enabled = false },
|
||||
pyflakes = { enabled = false },
|
||||
pycodestyle = { enabled = false },
|
||||
mccabe = { enabled = false },
|
||||
|
||||
-- Code refactor
|
||||
rope = { enabled = true },
|
||||
|
||||
-- Formatting
|
||||
black = { enabled = true },
|
||||
pyls_isort = { enabled = false },
|
||||
autopep8 = { enabled = false },
|
||||
yapf = { enabled = false },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
3
nvim/lua/modules/configs/completion/tabnine.lua
Normal file
3
nvim/lua/modules/configs/completion/tabnine.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
return function()
|
||||
require("cmp_tabnine.config"):setup({ max_line = 1000, max_num_results = 20, sort = true })
|
||||
end
|
||||
Reference in New Issue
Block a user