rework simple cmp and simple native lsp
This commit is contained in:
parent
77fc1c35c7
commit
f80bcc68b6
@ -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
|
||||||
|
|||||||
@ -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,
|
||||||
|
})
|
||||||
|
|||||||
@ -1,47 +1,81 @@
|
|||||||
-- 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"
|
||||||
@ -51,54 +85,3 @@ vim.opt.smartcase = true -- ...unless the query contains a capital letter
|
|||||||
-- "~/.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,
|
|
||||||
-- })
|
|
||||||
|
|||||||
@ -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)
|
||||||
},
|
--
|
||||||
config = function()
|
-- See :h blink-cmp-config-keymap for defining your own keymap
|
||||||
local cmp = require("cmp")
|
keymap = { preset = '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 = {
|
sources = {
|
||||||
{ name = "nvim_lsp" },
|
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||||
{ name = "luasnip" },
|
|
||||||
{ name = "buffer" },
|
|
||||||
{ name = "path" },
|
|
||||||
},
|
},
|
||||||
confirm_opts = {
|
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = false,
|
|
||||||
},
|
},
|
||||||
})
|
opts_extend = { "sources.default" }
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
|
||||||
}
|
|
||||||
@ -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"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@ -1,4 +1,20 @@
|
|||||||
local lsp_servers = {
|
return {
|
||||||
|
{
|
||||||
|
"mason-org/mason-lspconfig.nvim",
|
||||||
|
dependencies = {
|
||||||
|
{ "mason-org/mason.nvim", opts = {} },
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
{
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
version = "1.*",
|
||||||
|
},
|
||||||
|
-- Optional tools installer (safe to keep)
|
||||||
|
{ "WhoIsSethDaniel/mason-tool-installer.nvim" },
|
||||||
|
},
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
|
||||||
|
-- Single place to edit servers/tools in the future
|
||||||
|
lsp_servers = {
|
||||||
"lua_ls",
|
"lua_ls",
|
||||||
"ts_ls",
|
"ts_ls",
|
||||||
"texlab",
|
"texlab",
|
||||||
@ -10,278 +26,86 @@ local lsp_servers = {
|
|||||||
"clangd",
|
"clangd",
|
||||||
"rust_analyzer",
|
"rust_analyzer",
|
||||||
"gopls",
|
"gopls",
|
||||||
}
|
},
|
||||||
|
tools = {
|
||||||
local tools = {
|
|
||||||
"luacheck",
|
"luacheck",
|
||||||
"latexindent",
|
"latexindent",
|
||||||
"prettierd",
|
"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
|
opts = function(plugin)
|
||||||
dap.configurations.rust = {
|
-- Pull arrays from the plugin spec so you edit only once
|
||||||
{
|
return {
|
||||||
type = "codelldb",
|
ensure_installed = plugin.lsp_servers,
|
||||||
request = "launch",
|
automatic_enable = true, -- uses vim.lsp.enable()
|
||||||
name = "Launch file",
|
}
|
||||||
program = function()
|
|
||||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
|
|
||||||
end,
|
end,
|
||||||
cwd = "${workspaceFolder}",
|
|
||||||
stopOnEntry = false,
|
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
|
end
|
||||||
|
|
||||||
if detected_languages.cpp or detected_languages.c then
|
local function tb(fn)
|
||||||
dap.configurations.cpp = {
|
return function()
|
||||||
{
|
local ok, builtin = pcall(require, "telescope.builtin")
|
||||||
type = "codelldb",
|
if ok and builtin[fn] then
|
||||||
request = "launch",
|
builtin[fn]()
|
||||||
name = "Launch file",
|
else
|
||||||
program = function()
|
vim.notify("Telescope non disponibile", vim.log.levels.WARN)
|
||||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
end
|
||||||
end,
|
|
||||||
cwd = "${workspaceFolder}",
|
|
||||||
stopOnEntry = false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
dap.configurations.c = dap.configurations.cpp
|
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
map("<F5>", dap.continue, "DAP Continue")
|
map("n", "gd", tb("lsp_definitions"), "Goto Definition (Telescope)")
|
||||||
map("<F10>", dap.step_over, "DAP Step Over")
|
map("n", "gr", tb("lsp_references"), "Goto References (Telescope)")
|
||||||
map("<F11>", dap.step_into, "DAP Step Into")
|
map("n", "gI", tb("lsp_implementations"), "Goto Implementations (Telescope)")
|
||||||
map("<F12>", dap.step_out, "DAP Step Out")
|
map("n", "gt", tb("lsp_type_definitions"), "Goto Type Definitions (Telescope)")
|
||||||
map("<leader>b", dap.toggle_breakpoint, "Toggle Breakpoint")
|
map("n", "K", vim.lsp.buf.hover, "Hover")
|
||||||
map("<leader>B", function()
|
map("n", "<leader>rn", vim.lsp.buf.rename, "Rename")
|
||||||
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
|
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, "Code Action")
|
||||||
end, "Conditional Breakpoint")
|
map("n", "[d", vim.diagnostic.goto_prev, "Prev Diagnostic")
|
||||||
map("<leader>dr", dap.repl.open, "Open DAP REPL")
|
map("n", "]d", vim.diagnostic.goto_next, "Next Diagnostic")
|
||||||
map("<leader>dl", dap.run_last, "Run Last DAP")
|
map("n", "<leader>e", vim.diagnostic.open_float, "Line Diagnostics")
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
pcall(vim.lsp.inlay_hint.enable, true, { bufnr = bufnr })
|
||||||
"williamboman/mason.nvim",
|
end
|
||||||
dependencies = {
|
|
||||||
"williamboman/mason-lspconfig.nvim",
|
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
|
||||||
"nvim-telescope/telescope.nvim",
|
|
||||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
|
||||||
|
|
||||||
-- DAP dependencies
|
-- Capabilities da blink.cmp (unchanged)
|
||||||
"mfussenegger/nvim-dap",
|
local ok_blink, blink = pcall(require, "blink.cmp")
|
||||||
"jay-babu/mason-nvim-dap.nvim",
|
local capabilities = ok_blink and blink.get_lsp_capabilities() or nil
|
||||||
"rcarriga/nvim-dap-ui",
|
|
||||||
"theHamsta/nvim-dap-virtual-text",
|
|
||||||
"nvim-neotest/nvim-nio",
|
|
||||||
|
|
||||||
-- Formatting/Linting
|
-- Config globale per tutti i server (unchanged)
|
||||||
"nvimtools/none-ls.nvim",
|
vim.lsp.config("*", {
|
||||||
{
|
|
||||||
"folke/lazydev.nvim",
|
|
||||||
ft = "lua",
|
|
||||||
opts = {
|
|
||||||
library = {
|
|
||||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
-- Mason setup
|
|
||||||
require("mason").setup()
|
|
||||||
|
|
||||||
-- Install tools and DAP adapters
|
|
||||||
require("mason-tool-installer").setup({
|
|
||||||
ensure_installed = vim.list_extend(tools, dap_adapters),
|
|
||||||
automatic_installation = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- 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,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
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
|
-- Mason core
|
||||||
local dap, dapui = require("dap"), require("dapui")
|
local ok_mason, mason = pcall(require, "mason")
|
||||||
dapui.setup({
|
if ok_mason then
|
||||||
layouts = {
|
mason.setup()
|
||||||
{
|
end
|
||||||
elements = {
|
|
||||||
{ id = "scopes", size = 0.25 },
|
-- mason-lspconfig v2: single setup using arrays from plugin spec
|
||||||
{ id = "breakpoints", size = 0.25 },
|
local mlsp = require("mason-lspconfig")
|
||||||
{ id = "stacks", size = 0.25 },
|
mlsp.setup(opts)
|
||||||
{ id = "watches", size = 0.25 },
|
|
||||||
},
|
-- Optional: tools via mason-tool-installer using the same tools array
|
||||||
size = 40,
|
local ok_mti, mti = pcall(require, "mason-tool-installer")
|
||||||
position = "left",
|
if ok_mti and plugin.tools and #plugin.tools > 0 then
|
||||||
},
|
mti.setup({
|
||||||
{
|
ensure_installed = plugin.tools,
|
||||||
elements = { "repl", "console" },
|
run_on_start = true,
|
||||||
size = 10,
|
start_delay = 3000,
|
||||||
position = "bottom",
|
debounce_hours = 5,
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Auto-open/close DAP UI
|
|
||||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
|
||||||
dapui.open()
|
|
||||||
end
|
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,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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",
|
|
||||||
-- },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@ -3,17 +3,18 @@ return {
|
|||||||
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 = {
|
||||||
|
theme = "ivy",
|
||||||
hidden = true,
|
hidden = true,
|
||||||
prompt_prefix = "🔍 ",
|
prompt_prefix = "🔍 ",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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
7
nvim/main.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
const Page = () => {
|
||||||
|
const a: number[] = []
|
||||||
|
a.fill(1)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user