diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-29 19:32:50 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-29 19:32:50 +0100 |
commit | f2254f8ff19bc4268ed70245926f800342bbac40 (patch) | |
tree | 271a0e62f2dbeccf09be1b01e4260aa3482c4105 | |
parent | b51afe268a6015ce31cf9162545411dd9fce93ad (diff) |
checkpoint
-rw-r--r-- | after/ftplugin/c.lua | 16 | ||||
-rw-r--r-- | after/plugin/conform.lua | 2 | ||||
-rw-r--r-- | lua/config/lsp.lua | 73 | ||||
-rw-r--r-- | lua/config/set.lua | 6 |
4 files changed, 22 insertions, 75 deletions
diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua index 58f46a6..b5b06d0 100644 --- a/after/ftplugin/c.lua +++ b/after/ftplugin/c.lua @@ -1,3 +1,19 @@ +local function mapcmd(command) + return function() + vim.cmd(command) + end +end + local map = vim.keymap.set map("n", ",p", [[<cmd>s/\(\s*\)\(.\+\)/\1printf("\2: %d\\n", \2);<cr>]], { desc = "Surround var with printf" }) +map("n", ",i", function() + local word = vim.fn.expand("<cword>") + vim.cmd([[ + normal m' + 0/^#include/ + normal O + .!include.sh ]] .. word) + vim.cmd("normal ''") +end, { desc = "Include header for word under cursor" }) +map("n", ",f", mapcmd("CF"), { desc = "Toggle formatting" }) vim.o.commentstring = "// %s" diff --git a/after/plugin/conform.lua b/after/plugin/conform.lua index 3d2deed..7a8bbce 100644 --- a/after/plugin/conform.lua +++ b/after/plugin/conform.lua @@ -24,6 +24,8 @@ conform.formatters["clang-format"] = { .. "AllowShortIfStatementsOnASingleLine: true, " .. "AllowShortLoopsOnASingleLine: true, " .. "AllowAllArgumentsOnNextLine: true, " + .. "AllowShortCaseLabelsOnASingleLine: true, " + .. "BreakAfterReturnType: AllDefinitions, " .. "ColumnLimit: " .. vim.o.tw .. "}", diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 70c88d8..b50b4b6 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -11,6 +11,7 @@ local builtin = require("telescope.builtin") map("n", " <cr>", lbuf.code_action, { desc = "Code actions" }) map("n", "gd", lbuf.definition, { desc = "Definition" }) +map("i", "<C-k>", lbuf.hover) map("n", " lr", lbuf.rename, { desc = "Rename" }) map("n", " li", builtin.lsp_implementations, { desc = "Implementation" }) map("n", " ls", lbuf.signature_help, { desc = "Signature help" }) @@ -88,70 +89,6 @@ lspconfig.lua_ls.setup({ }, }) --- [[ nvim cmp ]] -cmp.setup({ - enabled = function() - if context.in_treesitter_capture("comment") == true or context.in_syntax_group("Comment") then - return false - else - return true - end - end, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - completion = { - autocomplete = false, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - ["<C-b>"] = cmp.mapping.scroll_docs(-4), - ["<C-f>"] = cmp.mapping.scroll_docs(4), - ["<C-Space>"] = cmp.mapping.complete(), - ["<C-c>"] = cmp.mapping.abort(), - ["<CR>"] = cmp.mapping({ - i = function(fallback) - if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) - else - fallback() - end - end, - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), - }), - }), - sources = cmp.config.sources({ - { - name = "nvim_lsp", - keyword_length = 3, - }, - -- { name = "luasnip" }, - }, { - -- { name = "buffer", max_item_count = 5 }, - { name = "path", max_item_count = 5 }, - }), - formatting = { - format = lspkind.cmp_format({ - mode = "symbol_text", - menu = { - buffer = "(Buffer)", - nvim_lsp = "(LSP)", - luasnip = "(LuaSnip)", - nvim_lua = "(Lua)", - latex_symbols = "(Latex)", - }, - }), - }, -}) - -vim.api.nvim_set_hl(0, "CmpItemMenu", { italic = true }) - -- rounded border around floating windows local _border = "rounded" vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { @@ -174,13 +111,5 @@ autocmd("LspAttach", { if vim.tbl_contains({ "null-ls" }, client.name) then -- blacklist lsp return end - require("lsp_signature").on_attach({ - hint_enable = false, - doc_lines = 0, - bind = true, - handler_opts = { - border = "rounded", - }, - }, args.bufnr) end, }) diff --git a/lua/config/set.lua b/lua/config/set.lua index bc28f22..469be72 100644 --- a/lua/config/set.lua +++ b/lua/config/set.lua @@ -6,8 +6,8 @@ opt.incsearch = true opt.conceallevel = 2 -- Enable line numbers by default -opt.number = true -opt.relativenumber = true +-- opt.number = true +-- opt.relativenumber = true -- Tab settings opt.tabstop = 4 @@ -41,7 +41,7 @@ opt.updatetime = 50 opt.timeoutlen = 300 -- Set completeopt to have a better completion experience -opt.completeopt = "menuone,noselect" +opt.completeopt = "" -- Enable true color support opt.termguicolors = true |