rework simple cmp and simple native lsp

This commit is contained in:
Dmitri 2025-09-22 23:05:49 +02:00
parent 77fc1c35c7
commit f80bcc68b6
Signed by: kanopo
GPG Key ID: 759ADD40E3132AC7
12 changed files with 271 additions and 638 deletions

View File

@ -1,8 +1,8 @@
root = true root = true
# Unix-style newlines with a newline ending every file # Unix-style newlines with a newline ending every file
[*] [*.lua]
end_of_line = lf end_of_line = lf
insert_final_newline = true insert_final_newline = true
indent_style = space indent_style = space
indent_size = 4 indent_size = 2

View File

@ -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 -- Highlight yanked text
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("TextYankPost", {
@ -28,7 +8,6 @@ vim.api.nvim_create_autocmd("TextYankPost", {
pattern = "*", pattern = "*",
}) })
-- Go to last cursor position when opening a file -- Go to last cursor position when opening a file
vim.api.nvim_create_autocmd("BufReadPost", { vim.api.nvim_create_autocmd("BufReadPost", {
callback = function() callback = function()
@ -41,3 +20,21 @@ vim.api.nvim_create_autocmd("BufReadPost", {
end end
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,
})

View File

@ -1,104 +1,87 @@
-- options.lua -- Leader keys (set early)
vim.opt.cmdheight = 0
-- Leader key for all the keymaps
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
-------------------------------------------------------------------------------- -- UI and appearance
-- -- GENERAL EDITOR BEHAVIOR vim.o.termguicolors = true -- 24-bit colors in TUI
-------------------------------------------------------------------------------- vim.o.cursorline = true -- highlight current line
vim.opt.clipboard = "unnamedplus" -- Use system clipboard vim.o.number = true -- absolute line numbers
vim.opt.writebackup = false -- Disable backup files vim.o.relativenumber = true -- relative line numbers
vim.opt.undofile = true -- Enable persistent undo vim.o.signcolumn = "yes" -- always show signcolumn
vim.opt.wrap = false -- Do not wrap lines vim.o.colorcolumn = "100" -- visual column guide
vim.opt.conceallevel = 2 -- Hide markdown syntax, etc. vim.o.winborder = "rounded" -- default floating window border
vim.opt.signcolumn = "yes" -- Always show the sign column to avoid resizing vim.o.cmdheight = 0 -- minimal command-line height (NVIM 0.10+)
vim.opt.timeoutlen = 300 -- Time to wait for a mapped sequence to complete vim.o.conceallevel = 2 -- conceal in Markdown/jsonc when appropriate
vim.opt.updatetime = 250 -- Faster completion and CursorHold updates vim.o.foldlevel = 0 -- start with folds closed (Treesitter can open)
vim.o.winborder = "rounded"
-- 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_perl_provider = 0
vim.g.loaded_ruby_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
-------------------------------------------------------------------------------- -- Netrw (disable if using an explorer plugin like oil.nvim; enable if you rely on netrw)
-- -- UI AND APPEARANCE vim.g.loaded_netrw = 0
-------------------------------------------------------------------------------- vim.g.loaded_netrwPlugin = 0
vim.opt.number = true -- Show line numbers -- If you need netrw again, set both back to nil or 0 and restart:
vim.opt.relativenumber = true -- Show relative line numbers -- vim.g.loaded_netrw = nil; vim.g.loaded_netrwPlugin = nil
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
-------------------------------------------------------------------------------- -- Filetype-specific indentation overrides (examples)
-- -- SEARCHING local ft_augroup = vim.api.nvim_create_augroup("FileTypeSettings", { clear = true })
--------------------------------------------------------------------------------
vim.opt.ignorecase = true -- Case-insensitive searching
vim.opt.smartcase = true -- ...unless the query contains a capital letter
-------------------------------------------------------------------------------- -- C-like and web files: 2 spaces (adjust as needed)
-- -- SPELL CHECKING (currently disabled) 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.spell = true
-- vim.opt.spelllang = "en,it" -- vim.opt.spelllang = "en,it"
-- local spell_dir = vim.fn.stdpath("data") .. "/spell" -- local spell_dir = vim.fn.stdpath("data") .. "/spell"
-- vim.opt.spellfile = { -- vim.opt.spellfile = {
-- spell_dir .. "/en.utf-8.add", -- spell_dir .. "/en.utf-8.add",
-- spell_dir .. "/it.utf-8.add", -- spell_dir .. "/it.utf-8.add",
-- "~/.config/nvim/spell/en.proj.spl", -- "~/.config/nvim/spell/en.proj.spl",
-- "~/.config/nvim/spell/it.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,
-- })

View File

@ -1,12 +1,12 @@
return { return {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
dependencies = { dependencies = {
"ellisonleao/gruvbox.nvim", "ellisonleao/gruvbox.nvim",
}, },
config = function() config = function()
local theme = require("gruvbox") local theme = require("gruvbox")
require("lualine").setup({ require("lualine").setup({
theme = theme, theme = theme,
}) })
end, end,
} }

View File

@ -1,107 +1,25 @@
return { return {
"hrsh7th/nvim-cmp", 'saghen/blink.cmp',
event = { "InsertEnter" }, -- optional: provides snippets for the snippet source
dependencies = { dependencies = { 'rafamadriz/friendly-snippets' },
"hrsh7th/cmp-nvim-lsp", version = '1.*',
"hrsh7th/cmp-buffer", opts = {
"hrsh7th/cmp-path", -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
"saadparwaiz1/cmp_luasnip", -- 'super-tab' for mappings similar to vscode (tab to accept)
{ -- 'enter' for enter to accept
"L3MON4D3/LuaSnip", -- 'none' for no mappings
dependencies = { --
"rafamadriz/friendly-snippets", -- 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
"onsails/lspkind-nvim", -- C-e: Hide menu
"js-everts/cmp-tailwind-colors" -- 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") opts_extend = { "sources.default" }
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({
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-c>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = 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",
}),
["<S-Tab>"] = 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,
} }

View File

@ -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", "<leader>a", function() harpoon:list():add() end)
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
end
}

View File

@ -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"
}
},
}

View File

@ -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("<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", "[R]ename Symbol")
map("<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", "[C]ode [A]ction")
map("K", "<cmd>lua vim.lsp.buf.hover()<CR>", "[K] Hover")
map("<leader>d", "<cmd>lua vim.diagnostic.open_float()<CR>", "[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("<F5>", dap.continue, "DAP Continue")
map("<F10>", dap.step_over, "DAP Step Over")
map("<F11>", dap.step_into, "DAP Step Into")
map("<F12>", dap.step_out, "DAP Step Out")
map("<leader>b", dap.toggle_breakpoint, "Toggle Breakpoint")
map("<leader>B", function()
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end, "Conditional Breakpoint")
map("<leader>dr", dap.repl.open, "Open DAP REPL")
map("<leader>dl", dap.run_last, "Run Last DAP")
end
return { return {
"williamboman/mason.nvim", {
"mason-org/mason-lspconfig.nvim",
dependencies = { dependencies = {
"williamboman/mason-lspconfig.nvim", { "mason-org/mason.nvim", opts = {} },
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
"hrsh7th/cmp-nvim-lsp", {
"nvim-telescope/telescope.nvim", "saghen/blink.cmp",
"WhoIsSethDaniel/mason-tool-installer.nvim", version = "1.*",
},
-- DAP dependencies -- Optional tools installer (safe to keep)
"mfussenegger/nvim-dap", { "WhoIsSethDaniel/mason-tool-installer.nvim" },
"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" } },
},
},
},
}, },
config = function() event = { "BufReadPre", "BufNewFile" },
-- Mason setup
require("mason").setup()
-- Install tools and DAP adapters -- Single place to edit servers/tools in the future
require("mason-tool-installer").setup({ lsp_servers = {
ensure_installed = vim.list_extend(tools, dap_adapters), "lua_ls",
automatic_installation = true, "ts_ls",
}) "texlab",
"marksman",
"docker_compose_language_service",
"dockerls",
"tailwindcss",
"cssls",
"clangd",
"rust_analyzer",
"gopls",
},
tools = {
"luacheck",
"latexindent",
"prettierd",
},
-- LSP setup opts = function(plugin)
require("mason-lspconfig").setup({ -- Pull arrays from the plugin spec so you edit only once
ensure_installed = lsp_servers, return {
automatic_installation = true, ensure_installed = plugin.lsp_servers,
automatic_enable = true, automatic_enable = true, -- uses vim.lsp.enable()
}) }
-- 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", "<leader>du", dapui.toggle, { desc = "Toggle DAP UI" })
end, 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", "<leader>rn", vim.lsp.buf.rename, "Rename")
map({ "n", "v" }, "<leader>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", "<leader>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,
},
} }

View File

@ -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",
-- },
},
}

View File

@ -1,38 +1,39 @@
return { return {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
tag = '0.1.8', tag = '0.1.8',
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', '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' }
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } },
}, config = function()
config = function() require('telescope').setup {
require('telescope').setup { pickers = {
pickers = { find_files = {
find_files = { theme = "ivy",
hidden = true, hidden = true,
prompt_prefix = "🔍 ", prompt_prefix = "🔍 ",
}, },
live_grep = { live_grep = {
hidden = true, theme = "ivy",
prompt_prefix = "🔍 ", hidden = true,
}, prompt_prefix = "🔍 ",
}, },
extensions = { },
fzf = { extensions = {
fuzzy = true, fzf = {
override_generic_sorter = true, fuzzy = true,
override_file_sorter = true, override_generic_sorter = true,
case_mode = "ignore_case", override_file_sorter = true,
} case_mode = "ignore_case",
}
} }
require('telescope').load_extension('fzf') }
end,
keys = {
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "[F]ind [F]iles" },
{ "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "[F]ind [H]elp" },
{ "<leader>fd", "<cmd>Telescope diagnostics<cr>", desc = "[F]ind [D]iadgnostics" },
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "[F]ind [G]rep" },
} }
require('telescope').load_extension('fzf')
end,
keys = {
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "[F]ind [F]iles" },
{ "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "[F]ind [H]elp" },
{ "<leader>fd", "<cmd>Telescope diagnostics<cr>", desc = "[F]ind [D]iadgnostics" },
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "[F]ind [G]rep" },
}
} }

View File

@ -1,37 +0,0 @@
return {
"folke/trouble.nvim",
opts = {}, -- for default options, refer to the configuration section for custom setup.
cmd = "Trouble",
keys = {
{
"<leader>xx",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "Diagnostics (Trouble)",
},
{
"<leader>xX",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<leader>cs",
"<cmd>Trouble symbols toggle focus=false<cr>",
desc = "Symbols (Trouble)",
},
{
"<leader>cl",
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
desc = "LSP Definitions / references / ... (Trouble)",
},
{
"<leader>xL",
"<cmd>Trouble loclist toggle<cr>",
desc = "Location List (Trouble)",
},
{
"<leader>xQ",
"<cmd>Trouble qflist toggle<cr>",
desc = "Quickfix List (Trouble)",
},
},
}

7
nvim/main.ts Normal file
View File

@ -0,0 +1,7 @@
const Page = () => {
const a: number[] = []
a.fill(1)
}