From edffdd8186eb1d12529c0b7ae88bfa449c79dd53 Mon Sep 17 00:00:00 2001 From: EnricoGuccii Date: Wed, 4 Mar 2026 01:26:14 +0100 Subject: nvim --- .config/nvim/init.lua | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++ nvim/init.lua | 159 -------------------------------------------- 2 files changed, 180 insertions(+), 159 deletions(-) create mode 100644 .config/nvim/init.lua delete mode 100644 nvim/init.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..eeeb653 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,180 @@ +vim.pack.add({ + { src = "https://github.com/neovim/nvim-lspconfig" }, + + { src = "https://github.com/hrsh7th/nvim-cmp" }, + { src = "https://github.com/hrsh7th/cmp-nvim-lsp" }, + { src = "https://github.com/L3MON4D3/LuaSnip" }, + { src = "https://github.com/saadparwaiz1/cmp_luasnip" }, + { src = "https://github.com/rafamadriz/friendly-snippets" }, + + { src = "https://github.com/nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, + + { src = "https://github.com/stevearc/oil.nvim" }, + { src = "https://github.com/echasnovski/mini.nvim" }, + + { src = "https://github.com/lukas-reineke/indent-blankline.nvim" }, + { src = "https://github.com/folke/which-key.nvim" }, + + { src = "https://github.com/windwp/nvim-autopairs" }, + { src = "https://github.com/nvim-tree/nvim-web-devicons" }, + { src = "https://github.com/WTFox/jellybeans.nvim" }, + { src = "https://github.com/norcalli/nvim-colorizer.lua" }, + +}) + +vim.g.mapleader = " " +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.clipboard = "unnamedplus" +vim.opt.termguicolors = true +vim.opt.expandtab = true +vim.opt.shiftwidth = 2 +vim.opt.tabstop = 2 +vim.opt.signcolumn = "yes" +vim.opt.scrolloff = 5 + +vim.api.nvim_create_autocmd("BufWritePre", { + callback = function() + vim.lsp.buf.format({ async = false }) + end, +}) + +vim.api.nvim_create_autocmd("TextYankPost", { + callback = function() + vim.highlight.on_yank({ timeout = 150 }) + end, +}) + +vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + -- Unset 'formatexpr' + vim.bo[args.buf].formatexpr = nil + -- Unset 'omnifunc' + vim.bo[args.buf].omnifunc = nil + -- Disable document colors + vim.lsp.document_color.enable(false, args.buf) + end, +}) + +require("nvim-treesitter").setup({ + ensure_installed = { + "lua", "vim", "bash", "json", "python", + "cpp", "css", "java", "c" + }, + highlight = { enable = true }, +}) + +require("colorizer").setup() + +require("ibl").setup({ + indent = { char = "▏" }, + scope = { enabled = false }, +}) + +require("nvim-autopairs").setup() +local cmp_autopairs = require("nvim-autopairs.completion.cmp") + +local capabilities = require("cmp_nvim_lsp").default_capabilities() + +vim.lsp.config("lua_ls", { + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + }, + }, +}) + +vim.lsp.config("pyright", { + capabilities = capabilities, +}) + + +vim.lsp.config("clangd", { + capabilities = capabilities, + cmd = { "clangd", "--compile-commands-dir=." }, +}) + +vim.lsp.config("html", { + capabilities = capabilities, +}) +vim.lsp.config("ts_ls", { + capabilities = capabilities, +}) + +vim.lsp.config("cssls", { + capabilities = capabilities, +}) + +vim.lsp.enable({ + "lua_ls", + "pyright", + "clangd", + "html", + "cssls", + "ts_ls", +}) + +require("luasnip.loaders.from_vscode").lazy_load() + +local cmp = require("cmp") +local luasnip = require("luasnip") + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, +}) + +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + +require("oil").setup({ + view_options = { show_hidden = true }, +}) +vim.keymap.set("n", "e", require("oil").open) + +require("mini.pick").setup() +vim.keymap.set("n", "p", function() + require("mini.pick").builtin.files() +end) + +require("which-key").setup() + + +vim.keymap.set("n", "d", "bdelete") +vim.keymap.set("n", "", "bnext") +vim.keymap.set("n", "", "bprevious") +vim.keymap.set("n", "K", vim.diagnostic.open_float) +vim.keymap.set("x", "p", '"_dP') + + +vim.cmd("colorscheme jellybeans") diff --git a/nvim/init.lua b/nvim/init.lua deleted file mode 100644 index 22f375c..0000000 --- a/nvim/init.lua +++ /dev/null @@ -1,159 +0,0 @@ -vim.pack.add({ - { src = "https://github.com/neovim/nvim-lspconfig" }, - { src = "https://github.com/hrsh7th/nvim-cmp" }, - { src = "https://github.com/hrsh7th/cmp-nvim-lsp" }, - { src = "https://github.com/L3MON4D3/LuaSnip" }, - { src = "https://github.com/saadparwaiz1/cmp_luasnip" }, - { src = "https://github.com/nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, - { src = "https://github.com/stevearc/oil.nvim" }, - { src = "https://github.com/echasnovski/mini.pick" }, - { src = "https://github.com/lukas-reineke/indent-blankline.nvim" }, - { src = "https://github.com/rafamadriz/friendly-snippets" }, - { src = "https://github.com/folke/which-key.nvim" }, - { src = "https://github.com/catppuccin/nvim" }, - { src = "https://github.com/windwp/nvim-autopairs" }, - { src = "https://github.com/Hoffs/omnisharp-extended-lsp.nvim" }, - { src = "https://github.com/linux-cultist/venv-selector.nvim" }, - { src = "https://github.com/romgrk/barbar.nvim" }, - { src = "https://github.com/nvim-tree/nvim-web-devicons" }, -}) - -vim.g.mapleader = " " -vim.o.number = true -vim.o.relativenumber = true -vim.o.clipboard = "unnamedplus" -vim.o.termguicolors = true -vim.o.expandtab = true -vim.o.shiftwidth = 2 -vim.o.tabstop = 2 -vim.o.signcolumn = "yes" -vim.o.scrolloff = 5 - -vim.api.nvim_create_autocmd("BufWritePre", { - callback = function(args) - vim.lsp.buf.format({ bufnr = args.buf }) - end, -}) - -vim.api.nvim_create_autocmd("TextYankPost", { - callback = function() - vim.highlight.on_yank({ higroup = "IncSearch", timeout = 150 }) - end, -}) - - -require("nvim-treesitter.configs").setup({ - ensure_installed = { "lua", "vim", "bash", "json", "python", "cpp", "css", "arduino", "java", "c_sharp" }, - highlight = { enable = true }, -}) - -require("ibl").setup({ - indent = { char = "▏" }, - scope = { enabled = true }, -}) - -require("nvim-autopairs").setup({ - map_cr = true, - map_bs = true, - check_ts = true, - fast_wrap = {}, -}) - -vim.keymap.set("i", "", function() - local col = vim.fn.col(".") - 1 - local line = vim.fn.getline(".") - local next_char = line:sub(col + 1, col + 1) - if next_char == '"' or next_char == "'" or next_char == ")" or next_char == "]" or next_char == "}" then - return "" - else - return "" - end -end, { expr = true, noremap = true }) - - -require("luasnip.loaders.from_vscode").lazy_load() -local lspconfig = require("lspconfig") -lspconfig.lua_ls.setup({ - settings = { - Lua = { - diagnostics = { globals = { "vim" } }, - workspace = { checkThirdParty = true }, - }, - }, -}) -lspconfig.pyright.setup({}) -lspconfig.jdtls.setup({}) -lspconfig.cssls.setup({}) -lspconfig.clangd.setup({}) - - -local pid = vim.fn.getpid() -lspconfig.omnisharp.setup({ - cmd = { "/usr/bin/omnisharp", "--languageserver", "--hostPID", tostring(pid) }, - enable_roslyn_analyzers = true, - organize_imports_on_format = true, - enable_import_completion = true, - handlers = { - ["textDocument/definition"] = require("omnisharp_extended").handler, - }, - capabilities = require('cmp_nvim_lsp').default_capabilities(), -}) - - - -vim.keymap.set("n", "d", "bdelete", { noremap = true, silent = true }) -vim.keymap.set("n", "", "bnext", { noremap = true, silent = true }) -vim.keymap.set("n", "", "bprevious", { noremap = true, silent = true }) -vim.keymap.set("n", "K", vim.diagnostic.open_float, { noremap = true, silent = true }) -vim.keymap.set("i", "", vim.lsp.buf.signature_help, { buffer = true }) -vim.keymap.set("x", "p", '"_dP', { desc = "aaaa" }) - -local cmp = require("cmp") -local cmp_autopairs = require("nvim-autopairs.completion.cmp") -local luasnip = require("luasnip") - -cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.confirm({ select = true }), - }), - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - }, -}) - -cmp.event:on( - "confirm_done", - cmp_autopairs.on_confirm_done() -) - -require("oil").setup({ - view_options = { - show_hidden = true, - }, -}) -vim.keymap.set("n", "e", require("oil").open) - -require("mini.pick").setup() -vim.keymap.set("n", "p", function() - require("mini.pick").builtin.files() -end, { desc = "Pick files" }) - -require("which-key").setup() - -require("catppuccin").setup { - color_overrides = { - mocha = { - base = "#121212" - }, - } -} -vim.cmd("colorscheme catppuccin-mocha") -vim.cmd(":hi statusline guibg=NONE") -- cgit v1.2.3