1
0

update nvim config for 0.11

This commit is contained in:
2025-03-29 13:54:48 +01:00
parent d0660edf21
commit 407f9c2c96
8 changed files with 90 additions and 35 deletions

View File

@@ -11,6 +11,7 @@
- tmux
- tmux-plugin-manager
- neovim
- lua-language-server
- stylua
- luacheck
- prettier

View File

@@ -0,0 +1,6 @@
globals = {
"vim",
}
read_globals = {
"Snacks",
}

View File

@@ -1,12 +0,0 @@
return {
cmd = { "lua-language-server" },
root_markers = { ".luarc.json", ".luarc.jsonc" },
filetypes = { "lua" },
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
},
},
}

View File

@@ -0,0 +1,17 @@
return {
cmd = { "lua-language-server" },
root_markers = { ".luarc.json", ".luarc.jsonc" },
filetypes = { "lua" },
settings = {
Lua = {
completion = { callSnippet = "Both" },
hint = { enable = true },
workspace = {
library = {
vim.env.VIMRUNTIME,
},
},
runtime = { version = "LuaJIT" },
},
},
}

View File

@@ -15,7 +15,9 @@ vim.w.signcolumn = "yes" -- Keep signcolumn on by default
vim.opt.updatetime = 250 -- Decrease update time
vim.opt.timeoutlen = 300 -- time to wait for a mapped sequence to complete (in milliseconds)
vim.opt.backup = false -- creates a backup file
vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
-- if a file is being edited by another program (or was written to file while editing with another program), it is not
-- allowed to be edited
vim.opt.writebackup = false
vim.opt.completeopt = "menuone,noselect" -- Set completeopt to have a better completion experience
vim.opt.termguicolors = true -- set termguicolors to enable highlight groups
vim.opt.whichwrap = "bs<>[]hl" -- which "horizontal" keys are allowed to travel to prev/next line
@@ -43,7 +45,9 @@ vim.opt.autoindent = true
vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages
vim.opt.iskeyword:append("-") -- hyphenated words recognized by searches
vim.opt.formatoptions:remove({ "c", "r", "o" }) -- don't insert the current comment leader automatically for auto-wrapping comments using 'textwidth', hitting <Enter> in insert mode, or hitting 'o' or 'O' in normal mode.
-- don't insert the current comment leader automatically for auto-wrapping comments using 'textwidth', hitting <Enter>
-- in insert mode, or hitting 'o' or 'O' in normal mode.
vim.opt.formatoptions:remove({ "c", "r", "o" })
vim.opt.runtimepath:remove("/usr/share/vim/vimfiles") -- separate vim plugins from neovim in case vim still in use
vim.opt.foldmethod = "expr"

View File

@@ -1,3 +1,4 @@
--- [[ LSP setup]]
vim.lsp.config("*", {
capabilities = {
textDocument = {
@@ -6,37 +7,68 @@ vim.lsp.config("*", {
},
},
},
root_markers = { ".git" },
})
vim.lsp.config("lua", {
filetypes = { "lua" },
})
vim.lsp.config("rust", {
filetypes = { "rust" },
})
vim.lsp.enable("lua")
vim.lsp.enable("luals")
vim.lsp.enable("rust")
-- vim.lsp.completion.enable(true)
---[[AUTOCOMPLETION SETUP
vim.o.completeopt = "menuone,noinsert,popup,fuzzy"
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("my.lsp", {}),
callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
if client:supports_method("textDocument/implementation") then
-- Create a keymap for vim.lsp.buf.implementation ...
end
-- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y|
if client:supports_method("textDocument/completion") then
-- Optional: trigger autocompletion on EVERY keypress. May be slow!
-- local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
-- client.server_capabilities.completionProvider.triggerCharacters = chars
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
end
client.server_capabilities.completionProvider.triggerCharacters = vim.split("qwertyuiopasdfghjklzxcvbnm. ", "")
vim.api.nvim_create_autocmd({ "TextChangedI" }, {
buffer = args.buf,
callback = function()
vim.lsp.completion.get()
end,
})
-- if client:supports_method("textDocument/implementation") then
-- Create a keymap for vim.lsp.buf.implementation ...
-- end
if client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
vim.lsp.inlay_hint.enable(true, { bufnr = vim.fn.bufnr() })
end
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
---
---[[Code required to add documentation popup for an item
local _, cancel_prev = nil, function() end
vim.api.nvim_create_autocmd("CompleteChanged", {
buffer = args.buf,
callback = function()
if client:supports_method("textDocument/implementation") then
cancel_prev()
local info = vim.fn.complete_info({ "selected" })
local completionItem =
vim.tbl_get(vim.v.completed_item, "user_data", "nvim", "lsp", "completion_item")
if nil == completionItem then
return
end
_, cancel_prev = vim.lsp.buf_request(
args.buf,
vim.lsp.protocol.Methods.completionItem_resolve,
completionItem,
function(err, item, ctx)
if not item then
return
end
local docs = (item.documentation or {}).value
local win = vim.api.nvim__complete_set(info["selected"], { info = docs })
if win.winid and vim.api.nvim_win_is_valid(win.winid) then
vim.treesitter.start(win.bufnr, "markdown")
vim.wo[win.winid].conceallevel = 3
end
end
)
end
end,
})
---]]
end,
})
---AUTOCOMPLETION SETUP END]]

View File

@@ -18,7 +18,7 @@ local function filestatus()
return ""
end
TabLine = function()
function _G.TabLine()
return table.concat({
tab_info(),
filestatus(),

View File

@@ -22,6 +22,13 @@ return {
vim.keymap.set("n", "<leader>l", function()
lint.try_lint()
end, { desc = "Trigger linting for current file" })
vim.keymap.set("n", "<leader>d", function()
if vim.diagnostic.config().virtual_lines then
vim.diagnostic.config({ virtual_lines = false })
else
vim.diagnostic.config({ virtual_lines = { current_line = true } })
end
end, { desc = "Toggle inline diagnostics" })
end,
},
}