Update nvim config to 0.11.1 standards.
This commit is contained in:
parent
fe23a8c0df
commit
ae1489527c
16 changed files with 45 additions and 88 deletions
|
|
@ -32,10 +32,10 @@ require("window_management").setup()
|
|||
require("format_handler").setup()
|
||||
|
||||
-- Set configs for servers and enable them in the Neovim LSP Client
|
||||
require("lsp/setup")
|
||||
require("lspsetup")
|
||||
|
||||
-- Set configs for nvim-dap so we can debug
|
||||
require("dap/setup")
|
||||
require("dapsetup")
|
||||
|
||||
-- See ":help vim.highlight.on_yank()"
|
||||
setup_yank_highlight()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"arrow.nvim": { "branch": "master", "commit": "6e0f726f55f99332dd726a53effd6813786b6d49" },
|
||||
"blink.cmp": { "branch": "main", "commit": "485c03400608cb6534bbf84da8c1c471fc4808c0" },
|
||||
"blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" },
|
||||
"codecompanion.nvim": { "branch": "main", "commit": "35b11dc4b292519a5c09fb2c0c0e8a8832e9e821" },
|
||||
"codesnap.nvim": { "branch": "main", "commit": "6400480aa6cc366cbd931146c429aaa64680dab9" },
|
||||
"copilot.vim": { "branch": "release", "commit": "a9228e015528c9307890c48083c925eb98a64a79" },
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
"incline.nvim": { "branch": "main", "commit": "27040695b3bbfcd3257669037bd008d1a892831d" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||
"leap.nvim": { "branch": "main", "commit": "346a16ef942635a8ca5ff92e603d07e7e8be6cbe" },
|
||||
"lspsaga.nvim": { "branch": "main", "commit": "4acafaf3455c57c94400e961636d979fb6ddd9fc" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "1ba400068bc178eb698b96ecfde82db59e7a7b8f" },
|
||||
"lspsaga.nvim": { "branch": "main", "commit": "501265c9b30b191ab5e5a66d104e72fb155cf3be" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "0ea56f91b7f51a37b749c050a5e5dfdd56b302b3" },
|
||||
"markview.nvim": { "branch": "main", "commit": "4f9ad36efe01c283aa886453ba75bf569c897c84" },
|
||||
"neogit": { "branch": "master", "commit": "97f83f1dc51dee41e08e3c7a8adf00e1083e3178" },
|
||||
"neovim-ayu": { "branch": "master", "commit": "f5da37a8ddd62fc3a7b28900c4d1b807a3582584" },
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
local utils = require("utils")
|
||||
local dap = require("dap")
|
||||
|
||||
local dir_path = "dap/adapters"
|
||||
local dir_path = "dap"
|
||||
utils.foreach(utils.get_file_names_in_dir(dir_path, "*.lua", true), function(adapter)
|
||||
dap.adapters[adapter] = require(dir_path .. "/" .. adapter)
|
||||
end)
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
local utils = require("utils")
|
||||
local inlay_hints_handler = require("inlay_hints_handler")
|
||||
local format_handler = require("format_handler")
|
||||
|
||||
local function chain_on_attach(...)
|
||||
local funcs = { ... }
|
||||
return function(client, bufnr)
|
||||
for _, func in ipairs(funcs) do
|
||||
func(client, bufnr)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function global_on_attach(client, bufnr)
|
||||
inlay_hints_handler.add_buffer(bufnr)
|
||||
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = 0 })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
format_handler.format()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
utils.set_keymap_list({
|
||||
{ "gd", function() vim.lsp.buf.definition({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } },
|
||||
{ "gD", function() vim.lsp.buf.declaration({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } },
|
||||
})
|
||||
end
|
||||
|
||||
local global_capabilities = require("blink.cmp").get_lsp_capabilities()
|
||||
global_capabilities.offsetEncoding = { "utf-16" }
|
||||
|
||||
vim.lsp.config("*", {
|
||||
capabilities = global_capabilities,
|
||||
handlers = {
|
||||
["textDocument/publishDiagnostics"] = vim.lsp.diagnostic.on_publish_diagnostics,
|
||||
},
|
||||
root_markers = { ".git" },
|
||||
})
|
||||
|
||||
-- Find all files in lua/lsp/servers and require them
|
||||
-- We use them to ensure that the servers are installed and configured
|
||||
local errors = {}
|
||||
local dir_path = "lsp/servers"
|
||||
utils.foreach(utils.get_file_names_in_dir(dir_path, "*.lua", true), function(server_name)
|
||||
local server_path = dir_path .. "/" .. server_name
|
||||
local result, conf = utils.xpcallmsg(
|
||||
function() return require(server_path) end,
|
||||
"Failed to require " .. server_path,
|
||||
errors
|
||||
)
|
||||
|
||||
if not result or type(conf) ~= "table" or vim.tbl_isempty(conf) or conf.cmd == nil then
|
||||
error("Invalid configuration for " .. server_name)
|
||||
return
|
||||
end
|
||||
|
||||
conf.on_attach = (function()
|
||||
if conf.on_attach then
|
||||
return chain_on_attach(global_on_attach, conf.on_attach)
|
||||
end
|
||||
|
||||
return global_on_attach
|
||||
end)()
|
||||
|
||||
-- These still throw errors when wrapped by xpcall.
|
||||
-- Wanted it to just handle incorrect input and let the runtime continue
|
||||
-- as it would if the require was successful when wrapped. That would be great
|
||||
-- for WIP LSP configuration, instead we have the ugly if statements above.
|
||||
vim.lsp.config(server_name, conf)
|
||||
vim.lsp.enable(server_name)
|
||||
end)
|
||||
|
||||
if #errors > 0 then
|
||||
error(table.concat(errors, "\n"))
|
||||
end
|
||||
39
nvim/lua/lspsetup.lua
Normal file
39
nvim/lua/lspsetup.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
local utils = require("utils")
|
||||
local inlay_hints_handler = require("inlay_hints_handler")
|
||||
local format_handler = require("format_handler")
|
||||
|
||||
vim.lsp.config("*", {
|
||||
capabilities = require("blink.cmp").get_lsp_capabilities(),
|
||||
root_markers = { ".git" },
|
||||
})
|
||||
|
||||
local servers = {}
|
||||
utils.foreach(utils.get_file_names_in_dir("../lsp", "*.lua", true), function(server_name)
|
||||
table.insert(servers, server_name)
|
||||
end)
|
||||
|
||||
vim.lsp.enable(servers)
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
local bufnr = args.buf
|
||||
assert(client, "LspAttach: client is nil")
|
||||
|
||||
inlay_hints_handler.add_buffer(bufnr)
|
||||
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = 0 })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
format_handler.format()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
utils.set_keymap_list({
|
||||
{ "gd", function() vim.lsp.buf.definition({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } },
|
||||
{ "gD", function() vim.lsp.buf.declaration({ reuse_win = true, }) end, { noremap = true, buffer = bufnr } },
|
||||
})
|
||||
end
|
||||
})
|
||||
|
|
@ -71,7 +71,4 @@ opt.list = false
|
|||
-- Sessions
|
||||
opt.sessionoptions = { "buffers", "curdir", "winsize", "winpos", "skiprtp" }
|
||||
|
||||
-- Rounded borders
|
||||
opt.winborder = "rounded"
|
||||
|
||||
return opt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue