Chore: Update May2025

This commit is contained in:
Ward Truyen
2025-05-04 00:34:02 +02:00
parent 30481d8b3d
commit 56c7eedc37
12 changed files with 416 additions and 15 deletions

View File

@@ -0,0 +1,199 @@
--$ autocomplete for C++ Rust and Lua
--$ URL: https://github.com/hrsh7th/nvim-cmp
--$ help: nvim-cmp
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
{
"L3MON4D3/LuaSnip",
build = (function()
-- Build Step is needed for regex support in snippets.
-- This step is not supported in many windows environments.
-- Remove the below condition to re-enable on windows.
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
return
end
return "make install_jsregexp"
end)(),
dependencies = {
-- `friendly-snippets` contains a variety of premade snippets.
{
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
},
},
},
-- Adds other completion capabilities.
-- nvim-cmp does not ship with all sources by default. They are split
-- into multiple repos for maintenance purposes.
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
{
-- This is the signature help plugin. Hints the parameters when using a function.
"ray-x/lsp_signature.nvim",
event = "VeryLazy",
config = function()
require("lsp_signature").setup({
bind = true, -- This is mandatory, otherwise border config won't get registered.
handler_opts = {
border = "rounded",
},
})
end,
},
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
-- For jumping around snippets
vim.keymap.set({ "i", "s" }, "<C-N>", function()
luasnip.jump(1)
end, { silent = true })
vim.keymap.set({ "i", "s" }, "<C-E>", function()
luasnip.jump(-1)
end, { silent = true })
-- Icons for completion window.
local cmp_kinds = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
luasnip.config.setup({})
-- For setting up max width of the window
local ELLIPSIS_CHAR = ""
local MAX_LABEL_WIDTH = 30
local MIN_LABEL_WIDTH = 20
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = {
completeopt = "menu,menuone,noinsert",
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
formatting = {
-- Max/min width setup
format = function(_, vim_item)
vim_item.kind = (cmp_kinds[vim_item.kind] or "") .. vim_item.kind
local label = vim_item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, MAX_LABEL_WIDTH)
if truncated_label ~= label then
vim_item.abbr = truncated_label .. ELLIPSIS_CHAR
elseif string.len(label) < MIN_LABEL_WIDTH then
local padding = string.rep(" ", MIN_LABEL_WIDTH - string.len(label))
vim_item.abbr = label .. padding
end
vim_item.menu = ""
return vim_item
end,
},
-- gray
vim.api.nvim_set_hl(0, "CmpItemAbbrDeprecated", { bg = "NONE", strikethrough = true, fg = "#808080" }),
-- blue
vim.api.nvim_set_hl(0, "CmpItemAbbrMatch", { bg = "NONE", fg = "#569CD6" }),
vim.api.nvim_set_hl(0, "CmpItemAbbrMatchFuzzy", { link = "CmpIntemAbbrMatch" }),
-- light blue
vim.api.nvim_set_hl(0, "CmpItemKindVariable", { bg = "NONE", fg = "#9CDCFE" }),
vim.api.nvim_set_hl(0, "CmpItemKindInterface", { link = "CmpItemKindVariable" }),
vim.api.nvim_set_hl(0, "CmpItemKindText", { link = "CmpItemKindVariable" }),
-- pink
vim.api.nvim_set_hl(0, "CmpItemKindFunction", { bg = "NONE", fg = "#C586C0" }),
vim.api.nvim_set_hl(0, "CmpItemKindMethod", { link = "CmpItemKindFunction" }),
-- front
vim.api.nvim_set_hl(0, "CmpItemKindKeyword", { bg = "NONE", fg = "#D4D4D4" }),
vim.api.nvim_set_hl(0, "CmpItemKindProperty", { link = "CmpItemKindKeyword" }),
vim.api.nvim_set_hl(0, "CmpItemKindUnit", { link = "CmpItemKindKeyword" }),
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = function()
if cmp.visible() then
cmp.confirm({ select = true })
else
cmp.complete({})
end
end,
}),
sources = {
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "path" },
-- { name = "buffer" },
},
})
-- `/` cmdline setup.
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
opts = {},
sources = {
{ name = "buffer" },
},
})
-- `:` cmdline setup.
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
opts = {},
sources = cmp.config.sources({
{ name = "path" },
}, {
{
name = "cmdline",
option = {
ignore_cmds = { "Man", "!" },
},
},
}),
})
end,
}

View File

@@ -8,7 +8,7 @@ return {
config = function()
require("bufferline").setup({
options = {
options = {
buffer_close_icon = '󰅖',
offsets = {
{
@@ -17,6 +17,15 @@ return {
separator = true,
},
},
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local s = " "
for e, n in pairs(diagnostics_dict) do
local sym = e == "error" and "" or (e == "warning" and "" or "")
s = s .. n .. sym
end
return s
end,
}
})
end,

View File

@@ -6,7 +6,7 @@ return {
priority = 1000,
config = function()
require("catppuccin").setup({ })
require("catppuccin").setup({})
vim.cmd.colorscheme("catppuccin")
end,
}

View File

@@ -0,0 +1,19 @@
return {
"lewis6991/gitsigns.nvim",
-- event = "BufReadPre",
config = function()
require("gitsigns").setup {
signs = {
-- add = { text = "│" },
-- change = { text = "│" },
delete = { text = "_", show_count = true },
-- topdelete = { text = "‾" },
-- changedelete = { text = "~" },
-- untracked = { text = "┆" },
},
numhl = true, -- Toggle with `:Gitsigns toggle_numhl`
linehl = true, -- Toggle with `:Gitsigns toggle_linehl`
}
end,
}

View File

@@ -0,0 +1,147 @@
return {
"neovim/nvim-lspconfig",
version = "*",
config = function()
local lspconfig = require("lspconfig")
vim.cmd([[autocmd! ColorScheme * highlight NormalFloat guibg=#1f2335]])
vim.cmd([[autocmd! ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335]])
-- Beautiful borders around LSP stuff like hover/signature_help
local border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
}
-- LSP settings (for overriding per client)
local handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }),
}
lspconfig.clangd.setup({
cmd = {
"clangd",
"--offset-encoding=utf-16",
},
handlers = handlers,
})
lspconfig.glsl_analyzer.setup({
filetypes = { "glsl", "vert", "tese", "frag", "geom", "comp", "vs", "fs" },
handlers = handlers,
})
-- diagnostics border
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
-- I would love to retrieve the severity level just here in order to modify opts.border
opts = opts or {}
opts.border = opts.border or border
return orig_util_open_floating_preview(contents, syntax, opts, ...)
end
-- adding filetypes to get glsl things
vim.filetype.add({
extension = {
vert = "glsl",
tesc = "glsl",
tese = "glsl",
frag = "glsl",
geom = "glsl",
comp = "glsl",
vs = "glsl",
fs = "glsl",
},
})
lspconfig.rust_analyzer.setup({
settings = {
["rust-analyzer"] = {},
},
handlers = handlers,
})
lspconfig.lua_ls.setup({
handlers = handlers,
})
-- These lsp keybinds only load when an LSP is attatched to the buffer.
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(event)
-- Enable completion triggered by <c-x><c-o>
vim.bo[event.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
local map = function(keys, func, desc)
vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
end
-- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>.
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
-- Find references for the word under your cursor.
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
-- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*.
map("<leader>ld", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition")
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map("<leader>ls", require("telescope.builtin").lsp_document_symbols, "document [S]ymbols")
-- Format file
map("<leader>lf", vim.lsp.buf.format, "[F]ormat")
-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
map(
"<leader>lw",
require("telescope.builtin").lsp_dynamic_workspace_symbols,
"[W]orkspace symbols"
)
map("<leader>lp", vim.diagnostic.goto_prev, "Go to [P]revious diagnostic message")
map("<leader>ln", vim.diagnostic.goto_next, "Go to [N]ext diagnostic message")
map("<leader>le", vim.diagnostic.open_float, "Show diagnostic [E]rror messages")
vim.diagnostic.config({ virtual_text = false })
map("<leader>lq", vim.diagnostic.setloclist, "Open diagnostic [Q]uickfix list")
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
map("<leader>lr", vim.lsp.buf.rename, "[R]ename")
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
map("<leader>la", vim.lsp.buf.code_action, "code [A]ction")
-- Opens a popup that displays documentation about the word under your cursor
-- See `:help K` for why this keymap.
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
map("<leader>th", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
end, "[T]oggle Inlay [H]ints")
end,
})
end,
}

View File

@@ -1,10 +1,18 @@
--$ LSP manager
--$ URL: https://github.com/williamboman/mason.nvim
--$ :Mason
return{
return {
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end,
opts = {
ensure_installed = {
"clangd",
"clang-format",
"codelldb",
},
},
}

View File

@@ -0,0 +1,16 @@
return {
-- The bar at the bottom
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("lualine").setup({
options = {
globalstatus = true, -- enable global statusline (have a single statusline
},
sections = {
lualine_x = { "filetype" },
},
})
end,
}

View File

@@ -23,6 +23,7 @@ return {
vim.keymap.set('n', '<leader>ps', function()
builtin.grep_string({ search = vim.fn.input("Grep > ") })
end)
vim.keymap.set('n', '<leader>vh', builtin.help_tags, {})
vim.keymap.set('n', '<leader>vh', builtin.help_tags, {desc = "Search [H]elp"})
vim.keymap.set('n', '<leader>vk', builtin.keymaps, {desc = "Search [K]eymaps"})
end
}

View File

@@ -16,8 +16,8 @@ return{
return 20
end,
})
vim.keymap.set('n', '<leader>tt', ":ToggleTerm name=BottomTerm<cr>")
vim.keymap.set('n', '<leader>tv', ":ToggleTerm direction=vertical name=VerticalTerm<cr>")
vim.keymap.set('n', '<leader>tf', ":ToggleTerm direction=float name=FloatTerm<cr>")
vim.keymap.set('n', '<leader>t', ":ToggleTerm name=BottomTerm<cr>")
--vim.keymap.set('n', '<leader>tv', ":ToggleTerm direction=vertical name=VerticalTerm<cr>")
--vim.keymap.set('n', '<leader>tf', ":ToggleTerm direction=float name=FloatTerm<cr>")
end,
}

View File

@@ -10,7 +10,7 @@ return {
configs.setup({
ensure_installed = {
"c", "lua", "vim", "vimdoc", "elixir", "javascript", "html", "python", "typescript"
"c", "lua", "vim", "vimdoc", "javascript", "html", "python", "typescript"
},
sync_install = false,
highlight = { enable = true },

View File

@@ -47,6 +47,7 @@ return {
{"<leader>vm", "<Cmd>marks<Cr>", desc = "Marks", },
{"<leader>vr", "<Cmd>registers<Cr>", desc = "Registers" },
{"<leader>h", "<Cmd>nohlsearch<Cr>", desc = "Stop Highlight" },
{"<leader>l", group = "LSP"},
})
end,
}

View File

@@ -1,3 +1,4 @@
vim.g.have_nerd_font = true -- use nerd_font
vim.opt.clipboard = 'unnamedplus' -- use system keyboard for yank