From 3ccb1a8c66a179c398e138d03b6a1b42ef61b848 Mon Sep 17 00:00:00 2001 From: AfonsoCMSousa Date: Wed, 17 Dec 2025 18:43:36 +0000 Subject: [PATCH] Improved NVIM overall --- lua/core/keymaps.lua | 37 +++++++++++++++++++++++++++++++++++++ lua/core/options.lua | 2 +- lua/plugins/lsp.lua | 19 ++++++------------- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua index f92de5d..35916e2 100644 --- a/lua/core/keymaps.lua +++ b/lua/core/keymaps.lua @@ -43,4 +43,41 @@ keymap.set("n", "", ":resize +2", { desc = "Resize Down" }) keymap.set("n", "", ":vertical resize -2", { desc = "Resize Left" }) keymap.set("n", "", ":vertical resize +2", { desc = "Resize Right" }) +-- Copy to system clipboard +keymap.set('n', 'y', '"+y') +keymap.set('v', 'y', '"+y') + +-- Snippet expansion (using LuaSnip) + +-- Function to write a standard C template +local function write_c_template() + local lines = { + "#include ", + "#include ", + "", + "int main(int argc, char *argv[]) {", + " printf(\"Hello World!\\n\");", + " return 0;", + "}", + } + vim.api.nvim_buf_set_lines(0, 0, -1, false, lines) +end + +-- Function to write a standard C++ template +local function write_cpp_template() + local lines = { + "#include ", + "using namespace std;", + "", + "int main() {", + " cout << \"Hello World!\" << endl;", + " return 0;", + "}", + } + vim.api.nvim_buf_set_lines(0, 0, -1, false, lines) +end + +-- Create the commands +vim.api.nvim_create_user_command("C", write_c_template, {}) +vim.api.nvim_create_user_command("Cpp", write_cpp_template, {}) diff --git a/lua/core/options.lua b/lua/core/options.lua index 7ee6dfc..4cf781f 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -28,7 +28,7 @@ opt.scrolloff = 8 -- Keep 8 lines above/below cursor opt.colorcolumn = "160" -- Show a line at 160 chars -- Clipboard -opt.clipboard = "unnamedplus" -- Use system clipboard +-- opt.clipboard = "unnamedplus" -- Use system clipboard -- Split windows opt.splitright = true -- Vertical split to the right diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 372cb3c..e1a8bb2 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -32,15 +32,6 @@ local servers = { lua_ls = { cmd = { "lua-language-server" } }, ts_ls = { cmd = { "typescript-language-server", "--stdio" } }, pyright = { cmd = { "pyright-langserver", "--stdio" } }, - clangd = { - cmd = { "clangd" }, - on_attach = on_attach, - capabilities = capabilities, - init_options = { - clangdFileStatus = true, - fallbackFlags = { "-style={UseTab: ForIndentation}" }, - } - }, } for name, config in pairs(servers) do @@ -51,8 +42,10 @@ for name, config in pairs(servers) do vim.lsp.start(vim.lsp.config[name]) end -require('lspconfig').asm_lsp.setup{ - cmd = { "asm-lsp" }, - filetypes = { "asm", "nasm", "gas" }, +require('lspconfig').asm_lsp.setup { + cmd = { "asm-lsp" }, + filetypes = { "asm", "nasm", "gas" }, +} +require('lspconfig').clangd.setup { + cmd = { "clangd", "--std=c++23" }, } -