chore(nvim): harpoon and other efficiency stuff

This commit is contained in:
Afonso Franco 2024-04-27 16:02:41 +01:00
parent f4fb84348d
commit 9c6e3a5d18
Signed by: afonso
SSH key fingerprint: SHA256:gkVPzsQQJzqi21ntQBV6pXTx4bYI53rFGI4XtvCpwd4
6 changed files with 122 additions and 124 deletions

View file

@ -25,8 +25,8 @@ vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
--quickfix keybinds
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<C-k>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<C-j>", "<cmd>cnext<CR>zz")
--buffer keybinds
vim.keymap.set("n", "<A-h>", "<cmd>bp<CR>")
vim.keymap.set("n", "<A-l>", "<cmd>bn<CR>")
@ -46,4 +46,4 @@ vim.g.jukit_pdf_viewer = 'zathura'
vim.g.jukit_mappings = 0
--Format Options
vim.opt.formatoptions:remove("ro")
--Sign gutter always on

View file

@ -19,38 +19,6 @@ if not lspkind_status_ok then
return
end
-- 󰃐 󰆩 󰙅 󰛡  󰅲 some other good icons
local kind_icons = {
Text = "󰉿",
Method = "m",
Function = "󰊕",
Constructor = "",
Field = "",
Variable = "󰆧",
Class = "󰌗",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "󰎠",
Enum = "",
Keyword = "󰌋",
Snippet = "",
Color = "󰏘",
File = "󰈙",
Reference = "",
Folder = "󰉋",
EnumMember = "",
Constant = "󰇽",
Struct = "",
Event = "",
Operator = "󰆕",
TypeParameter = "󰊄",
Copilot = "",
DB = "󰆼",
}
-- find more here: https://www.nerdfonts.com/cheat-sheet
cmp.setup({
snippet = {
expand = function(args)
@ -71,38 +39,25 @@ cmp.setup({
{ "i", "c" }
),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
-- Accept currently selected item. If none selected, do nothing.
["<C-k>"] = cmp.mapping(function(fallback)
if luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end),
["<C-j>"] = cmp.mapping(function(fallback)
["<C-h>"] = cmp.mapping(function()
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = lspkind.cmp_format({
mode = "symbol_text", -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
-- can also be a function to dynamically calculate max width such as
-- maxwidth = function() return math.floor(0.45 * vim.o.columns) end,
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
show_labelDetails = true, -- show labelDetails in menu. Disabled by default
mode = "symbol_text",
maxwidth = 50,
ellipsis_char = "...",
show_labelDetails = true,
-- The function below will be called before any actual modifications from lspkind
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
before = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = "[LSP]",
@ -113,11 +68,16 @@ cmp.setup({
end,
}),
},
preselect = cmp.PreselectMode.None,
sorting = {
priority_weight = 2,
comparators = {
cmp.config.compare.exact,
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.kind,
cmp.config.compare.recently_used,
cmp.config.compare.locality,
--Make entries that start with underline appear after
function(entry1, entry2)
@ -134,8 +94,8 @@ cmp.setup({
},
},
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
}, {

View file

@ -29,6 +29,15 @@ lazy.setup({
end,
},
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("plugins.harpoon")
end
},
"vimpostor/vim-tpipeline",
{
@ -61,7 +70,15 @@ lazy.setup({
"folke/todo-comments.nvim",
event = "VeryLazy",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {},
opts = {
vim.keymap.set("n", "]t", function()
require("todo-comments").jump_next()
end, { desc = "Next todo comment" }),
vim.keymap.set("n", "[t", function()
require("todo-comments").jump_prev()
end, { desc = "Previous todo comment" })
},
},
{
@ -181,6 +198,11 @@ lazy.setup({
end,
},
{
'leoluz/nvim-dap-go',
opts = {}
},
{
"williamboman/mason.nvim",
config = function()
@ -196,61 +218,12 @@ lazy.setup({
require("plugins.lspconfig")
end,
},
--Better quick fix
{
"folke/trouble.nvim",
branch = "dev",
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)",
},
},
opts = {
modes = {
mydiags = {
mode = "diagnostics", -- inherit from diagnostics mode
filter = {
any = {
buf = 0, -- current buffer
{
severity = vim.diagnostic.severity.ERROR, -- errors only
-- limit to files in the current project
function(item)
return item.filename:find(vim.loop.cwd(), 1, true)
end,
},
},
},
}
}
}
'kevinhwang91/nvim-bqf',
ft = 'qf'
},
'junegunn/fzf',
{
"stevearc/conform.nvim",
@ -293,12 +266,14 @@ lazy.setup({
-- Syntax Highlighting
{
"nvim-treesitter/nvim-treesitter",
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects'
},
config = function()
require("plugins.treesitter")
end,
},
"kaarmu/typst.vim",
--Sticky headers
{
@ -315,7 +290,11 @@ lazy.setup({
"nvim-telescope/telescope.nvim",
tag = "0.1.4",
-- or , branch = '0.1.x',
dependencies = { "nvim-lua/plenary.nvim" },
dependencies = {
"nvim-lua/plenary.nvim",
'nvim-telescope/telescope-ui-select.nvim',
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }
},
config = function()
require("plugins.telescope")
end,

View file

@ -12,6 +12,8 @@ vim.api.nvim_create_autocmd("LspAttach", {
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
vim.opt_local.signcolumn=numbers
local telescope = require("telescope.builtin")
local conform = require("conform")
@ -28,13 +30,13 @@ vim.api.nvim_create_autocmd("LspAttach", {
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, bufopts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
vim.keymap.set("n", "gd", telescope.lsp_definitions, bufopts)
vim.keymap.set("n", "gr", telescope.lsp_references, bufopts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
vim.keymap.set("n", "gi", telescope.lsp_implementations, bufopts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
vim.keymap.set("n", "<space>k", vim.lsp.buf.signature_help, bufopts)
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, bufopts)
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
vim.keymap.set("n", "gr", telescope.lsp_references, bufopts)
vim.keymap.set("n", "<space>ge", function() vim.diagnostic.goto_next() end, bufopts)
vim.keymap.set("n", "<space>gE", function() vim.diagnostic.goto_prev() end, bufopts)
vim.keymap.set("n", "<space>fo", function() conform.format({ lsp_fallback = true }) end, bufopts)
@ -54,7 +56,7 @@ mason_lspconfig.setup_handlers({
capabilities = capabilities,
})
end,
["gopls"] = function ()
["gopls"] = function()
lspconfig["gopls"].setup({
capabilities = capabilities,
settings = {
@ -79,11 +81,17 @@ mason_lspconfig.setup_handlers({
capabilities = capabilities,
settings = {
Lua = {
library = {
unpack(vim.api.nvim_get_runtime_file('', true))
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
diagnostics = {
globals = { 'vim' },
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
hint = { enable = true }
},

View file

@ -1,5 +1,41 @@
local telescope = require('telescope')
local actions = require("telescope.actions")
telescope.setup {
defaults = {
layout_strategy = "horizontal",
mappings = {
i = {
["<esc>"] = actions.close,
},
},
},
pickers = {
find_files = {
previewer = false,
layout_strategy = "vertical",
layout_config = {
height = 0.7,
width = 0.5
},
},
live_grep = {
only_sort_text = true,
previewer = true,
}
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_cursor {}
}
}
}
telescope.load_extension('fzf')
telescope.load_extension("ui-select")
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fs', builtin.treesitter, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})

View file

@ -4,11 +4,6 @@ if not present then
end
require('nvim-treesitter.install').update({ with_sync = true })
local present, orgmode = pcall(require, "orgmode")
if present then
require('orgmode').setup_ts_grammar()
end
local options = {
@ -22,6 +17,26 @@ local options = {
indent = {
enable = true,
},
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ab"] = "@block.outer",
["ib"] = "@block.inner",
},
selection_modes = {
['@block.outer'] = 'v', -- charwise
['@block.inner'] = 'v', -- charwise
['@function.outer'] = 'V', -- linewise
},
include_surrounding_whitespace = true,
},
},
}
treesitter.setup(options)