Improved NVIM overall

This commit is contained in:
AfonsoCMSousa 2025-12-17 18:43:36 +00:00
parent 5505642a8e
commit 3ccb1a8c66
3 changed files with 44 additions and 14 deletions

View File

@ -43,4 +43,41 @@ keymap.set("n", "<C-Down>", ":resize +2<CR>", { desc = "Resize Down" })
keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", { desc = "Resize Left" }) keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", { desc = "Resize Left" })
keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", { desc = "Resize Right" }) keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", { desc = "Resize Right" })
-- Copy to system clipboard
keymap.set('n', '<leader>y', '"+y')
keymap.set('v', '<leader>y', '"+y')
-- Snippet expansion (using LuaSnip)
-- Function to write a standard C template
local function write_c_template()
local lines = {
"#include <stdio.h>",
"#include <stdlib.h>",
"",
"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 <iostream>",
"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, {})

View File

@ -28,7 +28,7 @@ opt.scrolloff = 8 -- Keep 8 lines above/below cursor
opt.colorcolumn = "160" -- Show a line at 160 chars opt.colorcolumn = "160" -- Show a line at 160 chars
-- Clipboard -- Clipboard
opt.clipboard = "unnamedplus" -- Use system clipboard -- opt.clipboard = "unnamedplus" -- Use system clipboard
-- Split windows -- Split windows
opt.splitright = true -- Vertical split to the right opt.splitright = true -- Vertical split to the right

View File

@ -32,15 +32,6 @@ local servers = {
lua_ls = { cmd = { "lua-language-server" } }, lua_ls = { cmd = { "lua-language-server" } },
ts_ls = { cmd = { "typescript-language-server", "--stdio" } }, ts_ls = { cmd = { "typescript-language-server", "--stdio" } },
pyright = { cmd = { "pyright-langserver", "--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 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]) vim.lsp.start(vim.lsp.config[name])
end end
require('lspconfig').asm_lsp.setup{ require('lspconfig').asm_lsp.setup {
cmd = { "asm-lsp" }, cmd = { "asm-lsp" },
filetypes = { "asm", "nasm", "gas" }, filetypes = { "asm", "nasm", "gas" },
}
require('lspconfig').clangd.setup {
cmd = { "clangd", "--std=c++23" },
} }