mirror of
https://github.com/danielepintore/dotfiles.git
synced 2026-07-25 05:45:24 +02:00
feat: update nvim config to match 0.12 version
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
return {
|
||||
{ 'tpope/vim-fugitive',
|
||||
config = function ()
|
||||
vim.keymap.set("n", "<leader>gs", vim.cmd.Git);
|
||||
end
|
||||
}
|
||||
keys = {
|
||||
{ "<leader>gs", vim.cmd.Git, desc = "Open Vim Fugitive" },
|
||||
},
|
||||
dependencies = { "nvim-lua/plenary.nvim" }
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"ThePrimeagen/git-worktree.nvim",
|
||||
opt = {},
|
||||
config = function()
|
||||
require("telescope").load_extension("git_worktree")
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<leader>gw",
|
||||
function()
|
||||
require("telescope").extensions.git_worktree.git_worktrees()
|
||||
end,
|
||||
desc = "Git Worktree switch",
|
||||
},
|
||||
{
|
||||
"<leader>gn",
|
||||
function()
|
||||
require("telescope").extensions.git_worktree.create_git_worktree()
|
||||
end,
|
||||
desc = "Git Worktree create",
|
||||
},
|
||||
},
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +1,115 @@
|
||||
return {
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
keys = {
|
||||
{ "<space>e", vim.diagnostic.open_float, mode = "n", desc = "Open diagnostic float" },
|
||||
{ "[d", vim.diagnostic.goto_prev, mode = "n", desc = "Go to previous diagnostic" },
|
||||
{ "]d", vim.diagnostic.goto_next, mode = "n", desc = "Go to next diagnostic" },
|
||||
{ "<space>q", vim.diagnostic.setloclist, mode = "n", desc = "Set location list with diagnostics" },
|
||||
},
|
||||
config = function()
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||
callback = function(ev)
|
||||
-- Buffer local mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set('i', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set('n', '<leader>f', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, opts)
|
||||
end,
|
||||
})
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = {
|
||||
{ 'williamboman/mason.nvim', opts = {} },
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
},
|
||||
config = function()
|
||||
vim.diagnostic.config({ float = { border = 'rounded' }, virtual_text = false })
|
||||
|
||||
-- Set up diagnostics
|
||||
vim.diagnostic.config({
|
||||
float = {
|
||||
focusable = false,
|
||||
style = 'minimal',
|
||||
border = 'rounded',
|
||||
source = 'always',
|
||||
header = '',
|
||||
prefix = '',
|
||||
}
|
||||
})
|
||||
-- Define Servers
|
||||
local servers = {
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
-- Recognize the `vim` global variable
|
||||
globals = { "vim" }
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
pylsp = {},
|
||||
ts_ls = {},
|
||||
rust_analyzer = {},
|
||||
eslint = {},
|
||||
clangd = {},
|
||||
}
|
||||
|
||||
-- Set up cmp
|
||||
local cmp = require('cmp')
|
||||
local cmp_select_behavior = { behavior = cmp.SelectBehavior.Select }
|
||||
-- Prepare Native Capabilities
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
cmp.setup({
|
||||
preselect = cmp.PreselectMode.None,
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- `Enter` key to confirm completion
|
||||
['<CR>'] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() and cmp.get_active_entry() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
s = cmp.mapping.confirm({ select = true }),
|
||||
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
||||
}),
|
||||
-- Alt+Space to trigger completion menu
|
||||
['<M-Space>'] = cmp.mapping.complete(),
|
||||
-- Setup Servers
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
handlers = {
|
||||
function(server_name)
|
||||
local opts = servers[server_name] or {}
|
||||
opts.capabilities = capabilities
|
||||
vim.lsp.config(server_name, opts)
|
||||
vim.lsp.enable(server_name)
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
-- Tab to change item in completion menu
|
||||
['<Tab>'] = cmp.mapping.select_next_item(cmp_select_behavior),
|
||||
-- Shift+Tab goes to the previus item in the completion menu
|
||||
['<S-Tab>'] = cmp.mapping.select_prev_item(cmp_select_behavior),
|
||||
-- LspAttach (Keybindings & Activation)
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf }
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
|
||||
-- Navigate between documentation
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'path' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'buffer' },
|
||||
-- Copilot Source
|
||||
{ name = "copilot", group_index = 2 },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
dependencies = {
|
||||
'L3MON4D3/LuaSnip',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/nvim-cmp',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
{ 'j-hui/fidget.nvim', opts = {} },
|
||||
},
|
||||
},
|
||||
if client and client:supports_method('textDocument/completion') then
|
||||
vim.lsp.completion.enable(true, client.id, ev.buf, {
|
||||
autotrigger = true,
|
||||
autoselect = false,
|
||||
})
|
||||
end
|
||||
|
||||
{
|
||||
'mason-org/mason-lspconfig.nvim',
|
||||
dependencies = {
|
||||
{ 'mason-org/mason.nvim', opts = {} },
|
||||
'neovim/nvim-lspconfig',
|
||||
},
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, opts)
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
||||
|
||||
opts = {
|
||||
ensure_installed = { 'eslint', 'ts_ls', 'rust_analyzer', 'lua_ls', 'clangd', 'pyright', 'ruff' },
|
||||
},
|
||||
},
|
||||
vim.keymap.set('i', '<CR>', function()
|
||||
return vim.fn.pumvisible() ~= 0 and '<C-y>' or '<CR>'
|
||||
end, { expr = true, buffer = ev.buf })
|
||||
|
||||
{
|
||||
"L3MON4D3/LuaSnip", -- Snippet engine
|
||||
keys = {
|
||||
-- Move up in snippet fields
|
||||
{
|
||||
"<C-k>",
|
||||
function()
|
||||
local ls = require("luasnip")
|
||||
if ls.jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
end
|
||||
end,
|
||||
mode = { "i", "s" },
|
||||
desc = "Jump to the previous snippet field",
|
||||
silent = true,
|
||||
},
|
||||
-- Move down in snippet fields
|
||||
{
|
||||
"<C-j>",
|
||||
function()
|
||||
local ls = require("luasnip")
|
||||
if ls.expand_or_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
end
|
||||
end,
|
||||
mode = { "i", "s" },
|
||||
desc = "Expand or jump to the next snippet field",
|
||||
silent = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
vim.keymap.set('i', '<Tab>', function()
|
||||
return vim.fn.pumvisible() ~= 0 and '<C-n>' or '<Tab>'
|
||||
end, { expr = true, buffer = ev.buf })
|
||||
|
||||
vim.keymap.set('i', '<S-Tab>', function()
|
||||
return vim.fn.pumvisible() ~= 0 and '<C-p>' or '<S-Tab>'
|
||||
end, { expr = true, buffer = ev.buf })
|
||||
|
||||
vim.keymap.set('i', '<C-k>', function()
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes('<C-x><C-o>', true, false, true),
|
||||
'n', false
|
||||
)
|
||||
end, { buffer = ev.buf })
|
||||
|
||||
|
||||
-- Check if the server supports signature help and show function
|
||||
-- signature when typing
|
||||
-- Inside LspAttach:
|
||||
-- if client and client:supports_method('textDocument/signatureHelp') then
|
||||
-- -- Wrap the CursorMovedI in a group to prevent duplicates
|
||||
-- local sig_group = vim.api.nvim_create_augroup('UserSignatureHelp', { clear = false })
|
||||
-- vim.api.nvim_clear_autocmds({ group = sig_group, buffer = ev.buf })
|
||||
|
||||
-- vim.api.nvim_create_autocmd("CursorMovedI", {
|
||||
-- group = sig_group,
|
||||
-- buffer = ev.buf,
|
||||
-- callback = function()
|
||||
-- pcall(vim.lsp.buf.signature_help, { focusable = false, silent = true })
|
||||
-- end,
|
||||
-- })
|
||||
-- end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ return {
|
||||
"L3MON4D3/LuaSnip",
|
||||
dependencies = { "rafamadriz/friendly-snippets" },
|
||||
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
|
||||
enabled = false,
|
||||
-- install jsregexp (optional!).
|
||||
build = "make install_jsregexp",
|
||||
config = function ()
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.5",
|
||||
config = function()
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
['<Tab>'] = 'move_selection_previous',
|
||||
['<S-Tab>'] = 'move_selection_next',
|
||||
['<C-f>'] = 'preview_scrolling_up',
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<leader>ps', function()
|
||||
builtin.grep_string({ search = vim.fn.input("Grep > ") });
|
||||
end)
|
||||
vim.keymap.set('n', '<leader>gf', builtin.git_files, {})
|
||||
vim.keymap.set('n', 'gr', builtin.lsp_references)
|
||||
end,
|
||||
dependencies = { "nvim-lua/plenary.nvim" }
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.5",
|
||||
opts = {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
['<Tab>'] = 'move_selection_previous',
|
||||
['<S-Tab>'] = 'move_selection_next',
|
||||
['<C-f>'] = 'preview_scrolling_up',
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>pf", function() require("telescope.builtin").find_files() end },
|
||||
{ "<leader>ps", function() require("telescope.builtin").grep_string({ search = vim.fn.input("Grep > ") }) end },
|
||||
{ "<leader>gf", function() require("telescope.builtin").git_files() end },
|
||||
{ "<leader>gr", function() require("telescope.builtin").lsp_references() end },
|
||||
},
|
||||
dependencies = { "nvim-lua/plenary.nvim" }
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
return {
|
||||
{
|
||||
enabled = false,
|
||||
"christoomey/vim-tmux-navigator",
|
||||
cmd = {
|
||||
"TmuxNavigateLeft",
|
||||
"TmuxNavigateDown",
|
||||
"TmuxNavigateUp",
|
||||
"TmuxNavigateRight",
|
||||
"TmuxNavigatePrevious",
|
||||
},
|
||||
keys = {
|
||||
{ "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" },
|
||||
{ "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" },
|
||||
{ "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" },
|
||||
{ "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" },
|
||||
{ "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
|
||||
},
|
||||
}
|
||||
}
|
||||
25
.config/nvim/lua/plugins/tree-sitter.lua
Normal file
25
.config/nvim/lua/plugins/tree-sitter.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
return {
|
||||
"romus204/tree-sitter-manager.nvim",
|
||||
dependencies = {}, -- tree-sitter CLI must be installed system-wide
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"cpp",
|
||||
"css",
|
||||
"go",
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"python",
|
||||
"rust",
|
||||
"typescript",
|
||||
"yaml"
|
||||
}, -- list of parsers to install at the start of a neovim session
|
||||
-- Default Options
|
||||
-- ensure_installed = {}, -- list of parsers to install at the start of a neovim session
|
||||
-- border = nil, -- border style for the window (e.g. "rounded", "single"), if nil, use the default border style defined by 'vim.o.winborder'. See :h 'winborder' for more info.
|
||||
-- auto_install = false, -- if enabled, install missing parsers when editing a new file
|
||||
},
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
return {
|
||||
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate",
|
||||
config = function()
|
||||
require('nvim-treesitter.configs').setup({
|
||||
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||
ensure_installed = {"javascript", "typescript", "rust", "c", "lua", "vim", "vimdoc", "query" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
|
||||
-- List of parsers to ignore installing (for "all")
|
||||
-- ignore_install = { "javascript" },
|
||||
|
||||
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
||||
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
})
|
||||
end
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
return {
|
||||
"folke/trouble.nvim",
|
||||
opts = {}, -- for default options, refer to the configuration section for custom setup.
|
||||
opts = {},
|
||||
cmd = "Trouble",
|
||||
keys = {
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
return {
|
||||
{'mbbill/undotree',
|
||||
config = function ()
|
||||
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle)
|
||||
end
|
||||
}
|
||||
'mbbill/undotree',
|
||||
keys = {
|
||||
{ "<leader>u", vim.cmd.UndotreeToggle, desc = "Toggle Undotree" },
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user