diff --git a/nvim/.editorconfig b/nvim/.editorconfig index 29ac6fa..a5afba8 100644 --- a/nvim/.editorconfig +++ b/nvim/.editorconfig @@ -1,8 +1,8 @@ root = true # Unix-style newlines with a newline ending every file -[*] +[*.lua] end_of_line = lf insert_final_newline = true indent_style = space -indent_size = 4 +indent_size = 2 diff --git a/nvim/lua/kanopo/autocmds.lua b/nvim/lua/kanopo/autocmds.lua index 77a11d8..be321e9 100644 --- a/nvim/lua/kanopo/autocmds.lua +++ b/nvim/lua/kanopo/autocmds.lua @@ -1,23 +1,3 @@ --- autoformat on save file -vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if not client then return end - - if client.supports_method("textDocument/formatting") then - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = args.buf, - callback = function() - vim.lsp.buf.format({ - bufnr = args.buf, - id = client.id - }) - end - }) - end - end -}) - -- Highlight yanked text local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) vim.api.nvim_create_autocmd("TextYankPost", { @@ -28,7 +8,6 @@ vim.api.nvim_create_autocmd("TextYankPost", { pattern = "*", }) - -- Go to last cursor position when opening a file vim.api.nvim_create_autocmd("BufReadPost", { callback = function() @@ -41,3 +20,21 @@ vim.api.nvim_create_autocmd("BufReadPost", { end end, }) + +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('my.lsp', {}), + callback = function(args) + local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) + -- Usually not needed if server supports "textDocument/willSaveWaitUntil". + if not client:supports_method('textDocument/willSaveWaitUntil') + and client:supports_method('textDocument/formatting') then + vim.api.nvim_create_autocmd('BufWritePre', { + group = vim.api.nvim_create_augroup('my.lsp', { clear = false }), + buffer = args.buf, + callback = function() + vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 }) + end, + }) + end + end, +}) diff --git a/nvim/lua/kanopo/options.lua b/nvim/lua/kanopo/options.lua index aec32c0..b4f5816 100644 --- a/nvim/lua/kanopo/options.lua +++ b/nvim/lua/kanopo/options.lua @@ -1,104 +1,87 @@ --- options.lua -vim.opt.cmdheight = 0 - --- Leader key for all the keymaps +-- Leader keys (set early) vim.g.mapleader = " " vim.g.maplocalleader = " " --------------------------------------------------------------------------------- --- -- GENERAL EDITOR BEHAVIOR --------------------------------------------------------------------------------- -vim.opt.clipboard = "unnamedplus" -- Use system clipboard -vim.opt.writebackup = false -- Disable backup files -vim.opt.undofile = true -- Enable persistent undo -vim.opt.wrap = false -- Do not wrap lines -vim.opt.conceallevel = 2 -- Hide markdown syntax, etc. -vim.opt.signcolumn = "yes" -- Always show the sign column to avoid resizing -vim.opt.timeoutlen = 300 -- Time to wait for a mapped sequence to complete -vim.opt.updatetime = 250 -- Faster completion and CursorHold updates -vim.o.winborder = "rounded" +-- UI and appearance +vim.o.termguicolors = true -- 24-bit colors in TUI +vim.o.cursorline = true -- highlight current line +vim.o.number = true -- absolute line numbers +vim.o.relativenumber = true -- relative line numbers +vim.o.signcolumn = "yes" -- always show signcolumn +vim.o.colorcolumn = "100" -- visual column guide +vim.o.winborder = "rounded" -- default floating window border +vim.o.cmdheight = 0 -- minimal command-line height (NVIM 0.10+) +vim.o.conceallevel = 2 -- conceal in Markdown/jsonc when appropriate +vim.o.foldlevel = 0 -- start with folds closed (Treesitter can open) --- Disable unused built-in providers for faster startup +-- Splits +vim.o.splitright = true -- open vertical splits to the right +vim.o.splitbelow = true -- open horizontal splits below + +-- Editing behavior +vim.o.wrap = false -- do not wrap lines by default +vim.o.breakindent = true -- keep indentation on wrapped lines (if wrap is enabled later) +vim.o.clipboard = "unnamedplus" -- use system clipboard +vim.o.swapfile = false -- no swapfiles +vim.o.undofile = true -- persistent undo +vim.o.writebackup = false -- do not keep backup around + +-- Tabs and indentation (2-space default; override per-filetype with autocmds) +vim.o.expandtab = true +vim.o.tabstop = 2 +vim.o.softtabstop = 2 +vim.o.shiftwidth = 2 + +-- Search +vim.o.ignorecase = true -- case-insensitive +vim.o.smartcase = true -- unless uppercase is used + +-- Completion UX (good defaults for omni and popup behavior) +vim.o.completeopt = "menu,menuone,noinsert,noselect" +vim.o.shortmess = (vim.o.shortmess or "") .. "c" -- reduce completion messages + +-- Performance and input timing +vim.o.timeoutlen = 300 -- mapped sequence timeout +vim.o.updatetime = 250 -- faster CursorHold/diagnostic updates +vim.o.scrolloff = 10 -- context lines around cursor + +-- Fonts/icons (used by statuslines/UIs) +vim.g.have_nerd_font = true + +-- Providers (disable unused for faster startup) vim.g.loaded_perl_provider = 0 vim.g.loaded_ruby_provider = 0 -vim.g.loaded_netrw = 0 -- Disable netrw, as you likely use a plugin like nvim-tree +-- If you don't use Python providers via :CheckHealth, consider disabling too: +-- vim.g.loaded_python_provider = 0 +-- vim.g.loaded_python3_provider = 0 --------------------------------------------------------------------------------- --- -- UI AND APPEARANCE --------------------------------------------------------------------------------- -vim.opt.number = true -- Show line numbers -vim.opt.relativenumber = true -- Show relative line numbers -vim.opt.cursorline = true -- Highlight the current line -vim.opt.scrolloff = 10 -- Keep 10 lines of context around the cursor -vim.opt.termguicolors = true -- Enable 24-bit RGB color in the TUI -vim.o.foldlevel = 0 -- Start with all folds closed +-- Netrw (disable if using an explorer plugin like oil.nvim; enable if you rely on netrw) +vim.g.loaded_netrw = 0 +vim.g.loaded_netrwPlugin = 0 +-- If you need netrw again, set both back to nil or 0 and restart: +-- vim.g.loaded_netrw = nil; vim.g.loaded_netrwPlugin = nil --------------------------------------------------------------------------------- --- -- SEARCHING --------------------------------------------------------------------------------- -vim.opt.ignorecase = true -- Case-insensitive searching -vim.opt.smartcase = true -- ...unless the query contains a capital letter +-- Filetype-specific indentation overrides (examples) +local ft_augroup = vim.api.nvim_create_augroup("FileTypeSettings", { clear = true }) --------------------------------------------------------------------------------- --- -- SPELL CHECKING (currently disabled) --------------------------------------------------------------------------------- +-- C-like and web files: 2 spaces (adjust as needed) +vim.api.nvim_create_autocmd("FileType", { + group = ft_augroup, + pattern = { "c", "cpp", "objc", "objcpp", "javascript", "typescript", "tsx", "jsx" }, + callback = function() + vim.bo.tabstop = 2 + vim.bo.shiftwidth = 2 + vim.bo.expandtab = true + end, +}) + +-- Spell checking (optional; example) -- vim.opt.spell = true -- vim.opt.spelllang = "en,it" -- local spell_dir = vim.fn.stdpath("data") .. "/spell" -- vim.opt.spellfile = { --- spell_dir .. "/en.utf-8.add", --- spell_dir .. "/it.utf-8.add", --- "~/.config/nvim/spell/en.proj.spl", --- "~/.config/nvim/spell/it.proj.spl", +-- spell_dir .. "/en.utf-8.add", +-- spell_dir .. "/it.utf-8.add", +-- "~/.config/nvim/spell/en.proj.spl", +-- "~/.config/nvim/spell/it.proj.spl", -- } - --------------------------------------------------------------------------------- --- -- FILETYPE-SPECIFIC SETTINGS (AUTOCOMMANDS) --------------------------------------------------------------------------------- --- Create an autocommand group to prevent duplicate autocommands on reload -local ft_augroup = vim.api.nvim_create_augroup("FileTypeSettings", { clear = true }) - --- C, C++, etc: 4-space indentation -vim.api.nvim_create_autocmd("FileType", { - group = ft_augroup, - pattern = { "c", "cpp", "objc", "objcpp", "js", "ts", "tsx", "jsx" }, - callback = function() - -- Use vim.bo for buffer-local options - vim.bo.tabstop = 2 - vim.bo.shiftwidth = 2 - vim.bo.expandtab = true -- Use spaces instead of tabs - end, -}) - --- -- Web dev, scripting, etc: 2-space indentation --- vim.api.nvim_create_autocmd("FileType", { --- group = ft_augroup, --- pattern = { --- "lua", --- "python", --- "javascript", --- "typescript", --- "html", --- "css", --- "json", --- "yaml", --- "toml", --- "markdown", --- }, --- callback = function() --- vim.bo.tabstop = 2 --- vim.bo.shiftwidth = 2 --- vim.bo.expandtab = true --- end, --- }) --- --- -- LaTeX: 2-space indentation (example) --- vim.api.nvim_create_autocmd("FileType", { --- group = ft_augroup, --- pattern = { "tex" }, --- callback = function() --- vim.bo.tabstop = 2 --- vim.bo.shiftwidth = 2 --- vim.bo.expandtab = true --- end, --- }) diff --git a/nvim/lua/kanopo/plugins/bottom-bar.lua b/nvim/lua/kanopo/plugins/bottom-bar.lua index 080683e..5802a58 100644 --- a/nvim/lua/kanopo/plugins/bottom-bar.lua +++ b/nvim/lua/kanopo/plugins/bottom-bar.lua @@ -1,12 +1,12 @@ return { - "nvim-lualine/lualine.nvim", - dependencies = { - "ellisonleao/gruvbox.nvim", - }, - config = function() - local theme = require("gruvbox") - require("lualine").setup({ - theme = theme, - }) - end, + "nvim-lualine/lualine.nvim", + dependencies = { + "ellisonleao/gruvbox.nvim", + }, + config = function() + local theme = require("gruvbox") + require("lualine").setup({ + theme = theme, + }) + end, } diff --git a/nvim/lua/kanopo/plugins/cmp.lua b/nvim/lua/kanopo/plugins/cmp.lua index 939c9b3..9b11a81 100644 --- a/nvim/lua/kanopo/plugins/cmp.lua +++ b/nvim/lua/kanopo/plugins/cmp.lua @@ -1,107 +1,25 @@ return { - "hrsh7th/nvim-cmp", - event = { "InsertEnter" }, - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "saadparwaiz1/cmp_luasnip", - { - "L3MON4D3/LuaSnip", - dependencies = { - "rafamadriz/friendly-snippets", - }, - }, - "onsails/lspkind-nvim", - "js-everts/cmp-tailwind-colors" + 'saghen/blink.cmp', + -- optional: provides snippets for the snippet source + dependencies = { 'rafamadriz/friendly-snippets' }, + version = '1.*', + opts = { + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { preset = 'default' }, + sources = { + default = { 'lsp', 'path', 'snippets', 'buffer' }, }, - config = function() - local cmp = require("cmp") - local luasnip = require("luasnip") - require("luasnip/loaders/from_vscode").lazy_load() - local lspkind = require("lspkind") - - local check_backspace = function() - local col = vim.fn.col(".") - 1 - return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") - end - - -- La tua configurazione esistente per la INSERT MODE rimane invariata - cmp.setup({ - performance = { - debounce = 10, - throttle = 10, - max_view_entries = 10, - async_budget = 500, - fetching_timeout = 1000, - confirm_resolve_timeout = 2000, - filtering_context_budget = 200, - }, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expandable() then - luasnip.expand() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif check_backspace() then - fallback() - 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", - }), - }), - formatting = { - format = require("cmp-tailwind-colors").format - -- expandable_indicator = true, - -- fields = { "kind", "abbr", "menu" }, - -- format = lspkind.cmp_format({ - -- mode = "symbol", - -- maxwidth = 50, - -- ellipsis = "...", - -- show_labelDetails = true, - -- }), - }, - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }, - confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - }) - end, + }, + opts_extend = { "sources.default" } } diff --git a/nvim/lua/kanopo/plugins/harpoon.lua b/nvim/lua/kanopo/plugins/harpoon.lua deleted file mode 100644 index 019cdc2..0000000 --- a/nvim/lua/kanopo/plugins/harpoon.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - "ThePrimeagen/harpoon", - branch = "harpoon2", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope.nvim" - }, - config = function() - local harpoon = require('harpoon') - harpoon:setup({}) - vim.keymap.set("n", "a", function() harpoon:list():add() end) - vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) - end -} diff --git a/nvim/lua/kanopo/plugins/leetcode.lua b/nvim/lua/kanopo/plugins/leetcode.lua deleted file mode 100644 index dd5c63e..0000000 --- a/nvim/lua/kanopo/plugins/leetcode.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - "kawre/leetcode.nvim", - build = ":TSUpdate html", -- if you have `nvim-treesitter` installed - dependencies = { - 'nvim-telescope/telescope.nvim', - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", - }, - opts = { - logging = false, - lang = "typescript", - picker = { - provider = "telescope" - } - }, -} diff --git a/nvim/lua/kanopo/plugins/lsp.lua b/nvim/lua/kanopo/plugins/lsp.lua index b3b07c4..3a7767a 100644 --- a/nvim/lua/kanopo/plugins/lsp.lua +++ b/nvim/lua/kanopo/plugins/lsp.lua @@ -1,287 +1,111 @@ -local lsp_servers = { - "lua_ls", - "ts_ls", - "texlab", - "marksman", - "docker_compose_language_service", - "dockerls", - "tailwindcss", - "cssls", - "clangd", - "rust_analyzer", - "gopls", -} - -local tools = { - "luacheck", - "latexindent", - "prettierd", -} - --- DAP adapters that will be auto-installed based on your LSP servers -local dap_adapters = { -} - -local on_attach = function(_, bufnr) - local map = function(key, func, desc) - vim.keymap.set("n", key, func, { noremap = true, silent = true, desc = desc, buffer = bufnr }) - end - - local telescope = require("telescope.builtin") - - -- LSP mappings - map("rn", "lua vim.lsp.buf.rename()", "[R]ename Symbol") - map("ca", "lua vim.lsp.buf.code_action()", "[C]ode [A]ction") - map("K", "lua vim.lsp.buf.hover()", "[K] Hover") - map("d", "lua vim.diagnostic.open_float()", "[E]xplain Diagnostic") - map("gd", telescope.lsp_definitions, "[G]o [D]efinition") - map("gr", telescope.lsp_references, "[G]o [R]eferences") - map("gI", telescope.lsp_implementations, "[G]o [I]mplementations") -end - --- Auto-detect project type and setup DAP configurations -local function setup_dap_configs() - local dap = require("dap") - - -- Project detection patterns - local project_patterns = { - typescript = { "package.json", "tsconfig.json", "*.ts", "*.tsx" }, - javascript = { "package.json", "*.js", "*.jsx" }, - rust = { "Cargo.toml", "*.rs" }, - cpp = { "CMakeLists.txt", "Makefile", "*.cpp", "*.c", "*.h" }, - c = { "Makefile", "*.c", "*.h" }, - } - - local detected_languages = {} - - -- Detect project types - for lang, patterns in pairs(project_patterns) do - for _, pattern in ipairs(patterns) do - if vim.fn.glob(pattern) ~= "" then - detected_languages[lang] = true - break - end - end - end - - -- Setup configurations for detected languages - if detected_languages.typescript or detected_languages.javascript then - dap.configurations.typescript = { - { - type = "pwa-node", - request = "launch", - name = "Launch file", - program = "${file}", - cwd = "${workspaceFolder}", - }, - { - type = "pwa-node", - request = "attach", - name = "Attach", - processId = require("dap.utils").pick_process, - cwd = "${workspaceFolder}", - }, - } - dap.configurations.javascript = dap.configurations.typescript - end - - if detected_languages.rust then - dap.configurations.rust = { - { - type = "codelldb", - request = "launch", - name = "Launch file", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file") - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - }, - } - end - - if detected_languages.cpp or detected_languages.c then - dap.configurations.cpp = { - { - type = "codelldb", - request = "launch", - name = "Launch file", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - }, - } - dap.configurations.c = dap.configurations.cpp - end -end - --- Setup DAP keymaps -local function setup_dap_keymaps() - local dap = require("dap") - local map = function(key, func, desc) - vim.keymap.set("n", key, func, { noremap = true, silent = true, desc = desc }) - end - - map("", dap.continue, "DAP Continue") - map("", dap.step_over, "DAP Step Over") - map("", dap.step_into, "DAP Step Into") - map("", dap.step_out, "DAP Step Out") - map("b", dap.toggle_breakpoint, "Toggle Breakpoint") - map("B", function() - dap.set_breakpoint(vim.fn.input("Breakpoint condition: ")) - end, "Conditional Breakpoint") - map("dr", dap.repl.open, "Open DAP REPL") - map("dl", dap.run_last, "Run Last DAP") -end - return { - "williamboman/mason.nvim", + { + "mason-org/mason-lspconfig.nvim", dependencies = { - "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", - "hrsh7th/cmp-nvim-lsp", - "nvim-telescope/telescope.nvim", - "WhoIsSethDaniel/mason-tool-installer.nvim", - - -- DAP dependencies - "mfussenegger/nvim-dap", - "jay-babu/mason-nvim-dap.nvim", - "rcarriga/nvim-dap-ui", - "theHamsta/nvim-dap-virtual-text", - "nvim-neotest/nvim-nio", - - -- Formatting/Linting - "nvimtools/none-ls.nvim", - { - "folke/lazydev.nvim", - ft = "lua", - opts = { - library = { - { path = "${3rd}/luv/library", words = { "vim%.uv" } }, - }, - }, - }, + { "mason-org/mason.nvim", opts = {} }, + "neovim/nvim-lspconfig", + { + "saghen/blink.cmp", + version = "1.*", + }, + -- Optional tools installer (safe to keep) + { "WhoIsSethDaniel/mason-tool-installer.nvim" }, }, - config = function() - -- Mason setup - require("mason").setup() + event = { "BufReadPre", "BufNewFile" }, - -- Install tools and DAP adapters - require("mason-tool-installer").setup({ - ensure_installed = vim.list_extend(tools, dap_adapters), - automatic_installation = true, - }) + -- Single place to edit servers/tools in the future + lsp_servers = { + "lua_ls", + "ts_ls", + "texlab", + "marksman", + "docker_compose_language_service", + "dockerls", + "tailwindcss", + "cssls", + "clangd", + "rust_analyzer", + "gopls", + }, + tools = { + "luacheck", + "latexindent", + "prettierd", + }, - -- LSP setup - require("mason-lspconfig").setup({ - ensure_installed = lsp_servers, - automatic_installation = true, - automatic_enable = true, - }) - - -- None-ls setup - local null_ls = require("null-ls") - null_ls.setup({ - sources = { - null_ls.builtins.formatting.prettierd, - null_ls.builtins.formatting.latexindent, - }, - }) - - -- LSP server configurations - local capabilities = require("cmp_nvim_lsp").default_capabilities() - - for _, lsp_server in pairs(lsp_servers) do - local server_config = { - on_attach = on_attach, - capabilities = capabilities, - } - - if lsp_server == "texlab" then - server_config.settings = { - texlab = { - latexFormatter = "latexindent", - }, - } - end - - require("lspconfig")[lsp_server].setup(server_config) - end - - require("mason-nvim-dap").setup({ - ensure_installed = dap_adapters, - automatic_installation = true, - -- handlers = { - -- return function(config) - -- require("mason-nvim-dap").default_setup(config) - -- end, - -- - -- -- -- Custom adapter configurations - -- -- ["js-debug-adapter"] = function(config) - -- -- config.adapters = { - -- -- type = "server", - -- -- host = "localhost", - -- -- port = "${port}", - -- -- executable = { - -- -- command = "js-debug-adapter", - -- -- args = { "${port}" }, - -- -- }, - -- -- } - -- -- require("mason-nvim-dap").default_setup(config) - -- -- end, - -- }, - }) - - -- DAP UI setup - local dap, dapui = require("dap"), require("dapui") - dapui.setup({ - layouts = { - { - elements = { - { id = "scopes", size = 0.25 }, - { id = "breakpoints", size = 0.25 }, - { id = "stacks", size = 0.25 }, - { id = "watches", size = 0.25 }, - }, - size = 40, - position = "left", - }, - { - elements = { "repl", "console" }, - size = 10, - position = "bottom", - }, - }, - }) - - -- Auto-open/close DAP UI - dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() - end - dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() - end - dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() - end - - -- DAP Virtual Text - require("nvim-dap-virtual-text").setup({ - enabled = true, - enabled_commands = true, - highlight_changed_variables = true, - highlight_new_as_changed = false, - show_stop_reason = true, - commented = false, - }) - - -- Setup DAP configurations and keymaps - setup_dap_configs() - setup_dap_keymaps() - - -- Additional DAP UI keymap - vim.keymap.set("n", "du", dapui.toggle, { desc = "Toggle DAP UI" }) + opts = function(plugin) + -- Pull arrays from the plugin spec so you edit only once + return { + ensure_installed = plugin.lsp_servers, + automatic_enable = true, -- uses vim.lsp.enable() + } end, + + config = function(plugin, opts) + -- Keymaps e on_attach condiviso (unchanged) + local function on_attach(_, bufnr) + vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr }) + vim.api.nvim_set_option_value("tagfunc", "v:lua.vim.lsp.tagfunc", { buf = bufnr }) + + local function map(mode, lhs, rhs, desc) + vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, noremap = true, silent = true, desc = desc }) + end + + local function tb(fn) + return function() + local ok, builtin = pcall(require, "telescope.builtin") + if ok and builtin[fn] then + builtin[fn]() + else + vim.notify("Telescope non disponibile", vim.log.levels.WARN) + end + end + end + + map("n", "gd", tb("lsp_definitions"), "Goto Definition (Telescope)") + map("n", "gr", tb("lsp_references"), "Goto References (Telescope)") + map("n", "gI", tb("lsp_implementations"), "Goto Implementations (Telescope)") + map("n", "gt", tb("lsp_type_definitions"), "Goto Type Definitions (Telescope)") + map("n", "K", vim.lsp.buf.hover, "Hover") + map("n", "rn", vim.lsp.buf.rename, "Rename") + map({ "n", "v" }, "ca", vim.lsp.buf.code_action, "Code Action") + map("n", "[d", vim.diagnostic.goto_prev, "Prev Diagnostic") + map("n", "]d", vim.diagnostic.goto_next, "Next Diagnostic") + map("n", "e", vim.diagnostic.open_float, "Line Diagnostics") + + pcall(vim.lsp.inlay_hint.enable, true, { bufnr = bufnr }) + end + + -- Capabilities da blink.cmp (unchanged) + local ok_blink, blink = pcall(require, "blink.cmp") + local capabilities = ok_blink and blink.get_lsp_capabilities() or nil + + -- Config globale per tutti i server (unchanged) + vim.lsp.config("*", { + on_attach = on_attach, + capabilities = capabilities, + }) + + -- Mason core + local ok_mason, mason = pcall(require, "mason") + if ok_mason then + mason.setup() + end + + -- mason-lspconfig v2: single setup using arrays from plugin spec + local mlsp = require("mason-lspconfig") + mlsp.setup(opts) + + -- Optional: tools via mason-tool-installer using the same tools array + local ok_mti, mti = pcall(require, "mason-tool-installer") + if ok_mti and plugin.tools and #plugin.tools > 0 then + mti.setup({ + ensure_installed = plugin.tools, + run_on_start = true, + start_delay = 3000, + debounce_hours = 5, + }) + end + end, + }, } diff --git a/nvim/lua/kanopo/plugins/precognition.lua b/nvim/lua/kanopo/plugins/precognition.lua deleted file mode 100644 index ead2fa5..0000000 --- a/nvim/lua/kanopo/plugins/precognition.lua +++ /dev/null @@ -1,30 +0,0 @@ -return { - "tris203/precognition.nvim", - event = "VeryLazy", - opts = { - startVisible = false, - -- showBlankVirtLine = true, - -- highlightColor = { link = "Comment" }, - -- hints = { - -- Caret = { text = "^", prio = 2 }, - -- Dollar = { text = "$", prio = 1 }, - -- MatchingPair = { text = "%", prio = 5 }, - -- Zero = { text = "0", prio = 1 }, - -- w = { text = "w", prio = 10 }, - -- b = { text = "b", prio = 9 }, - -- e = { text = "e", prio = 8 }, - -- W = { text = "W", prio = 7 }, - -- B = { text = "B", prio = 6 }, - -- E = { text = "E", prio = 5 }, - -- }, - -- gutterHints = { - -- G = { text = "G", prio = 10 }, - -- gg = { text = "gg", prio = 9 }, - -- PrevParagraph = { text = "{", prio = 8 }, - -- NextParagraph = { text = "}", prio = 8 }, - -- }, - -- disabled_fts = { - -- "startify", - -- }, - }, -} diff --git a/nvim/lua/kanopo/plugins/telescope.lua b/nvim/lua/kanopo/plugins/telescope.lua index d5c3c14..134661d 100644 --- a/nvim/lua/kanopo/plugins/telescope.lua +++ b/nvim/lua/kanopo/plugins/telescope.lua @@ -1,38 +1,39 @@ return { - 'nvim-telescope/telescope.nvim', - tag = '0.1.8', - dependencies = { - 'nvim-lua/plenary.nvim', - -- { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release' } - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } - }, - config = function() - require('telescope').setup { - pickers = { - find_files = { - hidden = true, - prompt_prefix = "🔍 ", - }, - live_grep = { - hidden = true, - prompt_prefix = "🔍 ", - }, - }, - extensions = { - fzf = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = "ignore_case", - } - } + 'nvim-telescope/telescope.nvim', + tag = '0.1.8', + dependencies = { + 'nvim-lua/plenary.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } + }, + config = function() + require('telescope').setup { + pickers = { + find_files = { + theme = "ivy", + hidden = true, + prompt_prefix = "🔍 ", + }, + live_grep = { + theme = "ivy", + hidden = true, + prompt_prefix = "🔍 ", + }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "ignore_case", } - require('telescope').load_extension('fzf') - end, - keys = { - { "ff", "Telescope find_files", desc = "[F]ind [F]iles" }, - { "fh", "Telescope help_tags", desc = "[F]ind [H]elp" }, - { "fd", "Telescope diagnostics", desc = "[F]ind [D]iadgnostics" }, - { "fg", "Telescope live_grep", desc = "[F]ind [G]rep" }, + } } + require('telescope').load_extension('fzf') + end, + keys = { + { "ff", "Telescope find_files", desc = "[F]ind [F]iles" }, + { "fh", "Telescope help_tags", desc = "[F]ind [H]elp" }, + { "fd", "Telescope diagnostics", desc = "[F]ind [D]iadgnostics" }, + { "fg", "Telescope live_grep", desc = "[F]ind [G]rep" }, + } } diff --git a/nvim/lua/kanopo/plugins/trouble.lua b/nvim/lua/kanopo/plugins/trouble.lua deleted file mode 100644 index e3ae746..0000000 --- a/nvim/lua/kanopo/plugins/trouble.lua +++ /dev/null @@ -1,37 +0,0 @@ -return { - "folke/trouble.nvim", - opts = {}, -- for default options, refer to the configuration section for custom setup. - cmd = "Trouble", - keys = { - { - "xx", - "Trouble diagnostics toggle", - desc = "Diagnostics (Trouble)", - }, - { - "xX", - "Trouble diagnostics toggle filter.buf=0", - desc = "Buffer Diagnostics (Trouble)", - }, - { - "cs", - "Trouble symbols toggle focus=false", - desc = "Symbols (Trouble)", - }, - { - "cl", - "Trouble lsp toggle focus=false win.position=right", - desc = "LSP Definitions / references / ... (Trouble)", - }, - { - "xL", - "Trouble loclist toggle", - desc = "Location List (Trouble)", - }, - { - "xQ", - "Trouble qflist toggle", - desc = "Quickfix List (Trouble)", - }, - }, -} diff --git a/nvim/main.ts b/nvim/main.ts new file mode 100644 index 0000000..d4556ee --- /dev/null +++ b/nvim/main.ts @@ -0,0 +1,7 @@ +const Page = () => { + const a: number[] = [] + a.fill(1) + + +} +