nvim lazy working noice

This commit is contained in:
Tiago Sousa 2024-01-27 18:23:43 +00:00
parent d7d1923e05
commit f1eee5e135
50 changed files with 638 additions and 605 deletions

View file

@ -1,4 +1,3 @@
require("tsousa.packer")
require("tsousa.set")
require("tsousa.remap")

View file

@ -23,14 +23,5 @@ vim.keymap.set("v", "<leader>d", "\"_d")
-- This is going to get me cancelled
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<leader>f", function()
vim.lsp.buf.format()
end)
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
vim.keymap.set("n", "<leader>s", ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>")
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })

View file

@ -1,3 +1,4 @@
vim.opt.guicursor=""
vim.opt.nu = true
vim.opt.relativenumber = true
@ -38,4 +39,6 @@ vim.opt.updatetime = 50
-- Don't pass messages to |ins-completion-menu|.
vim.opt.shortmess:append("c")
vim.opt.colorcolumn="80"
vim.g.mapleader = " "

View file

@ -1,6 +0,0 @@
local config = {
cmd = { '/home/tsousa/.local/share/nvim/mason/bin/jdtls' },
root_dir = vim.fs.dirname(vim.fs.find({ '.gradlew', '.git', 'mvnw' }, { upward = true })[1]),
}
require('jdtls').start_or_attach(config)

View file

@ -1,4 +0,0 @@
vim.bo.filetype = "tex"
vim.bo.syntax = "lhaskell"

View file

@ -0,0 +1,34 @@
{
"LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"dressing.nvim": { "branch": "master", "commit": "0e88293ce3459f4bb310125f3366304af6dc7990" },
"fidget.nvim": { "branch": "main", "commit": "3a93300c076109d86c7ce35ec67a8034ae6ba9db" },
"gruvbox.nvim": { "branch": "main", "commit": "4176b0b720db0c90ab4030e5c1b4893faf41fd51" },
"harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" },
"lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" },
"lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "b9084b1f42f790d6230dc66dbcb6bcc35b148552" },
"mason.nvim": { "branch": "main", "commit": "dcd0ea30ccfc7d47e879878d1270d6847a519181" },
"none-ls.nvim": { "branch": "main", "commit": "912f81829e9ab4ee3d54c3ea5a304c264f0003bc" },
"nvim": { "branch": "main", "commit": "afab7ec2a79c7127627dede79c0018b6e45663d0" },
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
"nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" },
"nvim-treesitter": { "branch": "master", "commit": "b4138891b3454beeb14eef171c91c92377fcd715" },
"nvim-treesitter-context": { "branch": "master", "commit": "9c06b115abc57c99cf0aa81dc29490f5001f57a1" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "19a91a38b02c1c28c14e0ba468d20ae1423c39b2" },
"nvim-web-devicons": { "branch": "master", "commit": "b427ac5f9dff494f839e81441fb3f04a58cbcfbc" },
"orgmode": { "branch": "master", "commit": "ab045e3084d5987e8939d25d69b09baaf762278c" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"telescope.nvim": { "branch": "master", "commit": "2f3857c25bbd00ed7ac593c9d4071906369e4d20" },
"todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" },
"undotree": { "branch": "master", "commit": "d9c8b4ef872e078e8c4080812e5a3ed56d151c00" },
"vim-fugitive": { "branch": "master", "commit": "854a8df0d06b8d3fcb30fa7f2b08c62b553eee3b" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }
}

View file

@ -1,3 +1,34 @@
require("tsousa.packer")
require("tsousa.set")
require("tsousa.remap")
require("tsousa.lazy")
local augroup = vim.api.nvim_create_augroup
local TsousaGroup = augroup('TsousaGroup', {})
local autocmd = vim.api.nvim_create_autocmd
local yank_group = augroup('HighlightYank', {})
function R(name)
require("plenary.reload").reload_module(name)
end
autocmd('TextYankPost', {
group = yank_group,
pattern = '*',
callback = function()
vim.highlight.on_yank({
higroup = 'IncSearch',
timeout = 40,
})
end,
})
autocmd({ "BufWritePre" }, {
group = TsousaGroup,
pattern = "*",
command = [[%s/\s\+$//e]],
})
vim.g.netrw_browse_split = 0
vim.g.netrw_banner = 0
vim.g.netrw_winsize = 25

View file

@ -0,0 +1,36 @@
return {
{
"catppuccin/nvim",
priority = 1000,
config = function()
require("catppuccin").setup({
flavour = "macchiato", -- latte, frappe, macchiato, mocha
transparent_background = true,
term_colors = false,
integrations = {
cmp = true,
gitsigns = true,
telescope = true,
treesitter = true,
treesitter_context = true,
},
})
vim.cmd.colorscheme("catppuccin")
end
},
{
"ellisonleao/gruvbox.nvim",
config = function()
require("gruvbox").setup({
italic = {
strings = false,
comments = true,
operators = false,
folds = true,
},
transparent_mode = true,
})
end
},
}

View file

@ -7,9 +7,9 @@ return {
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<C-j>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-k>", function() ui.nav_file(2) end)
vim.keymap.set("n", "<C-l>", function() ui.nav_file(3) end)
vim.keymap.set("n", "<C-;>", function() ui.nav_file(4) end)
vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-j>", function() ui.nav_file(2) end)
vim.keymap.set("n", "<C-k>", function() ui.nav_file(3) end)
vim.keymap.set("n", "<C-l>", function() ui.nav_file(4) end)
end
}

View file

@ -5,5 +5,5 @@ return {
"tpope/vim-surround",
"nvim-lualine/lualine.nvim",
"nvim-treesitter/playground",
"runoshun/vim-alloy",
"j-hui/fidget.nvim",
}

View file

@ -0,0 +1,278 @@
return {
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
'hrsh7th/cmp-nvim-lsp', -- lsp
'hrsh7th/cmp-nvim-lua', -- Nvim API completions
'hrsh7th/cmp-nvim-lsp-signature-help', -- Show function signatures
'hrsh7th/cmp-buffer', --buffer completions
'hrsh7th/cmp-path', --path completions
'hrsh7th/cmp-cmdline', --cmdline completions
'L3MON4D3/LuaSnip',
},
config = function()
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then
return
end
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
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 = "󰊄",
}
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
-- Accept currently selected item. If none selected, do nothing.
["<CR>"] = cmp.mapping.confirm { select = false },
["<C-k>"] = cmp.mapping(function(fallback)
if luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end),
["<C-j>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end
),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, {
"i",
"s",
}),
["<C-p>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, {
"i",
"s",
}),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({
nvim_lsp = "(LSP)",
luasnip = "(Snippet)",
buffer = "(Text)",
nvim_lsp_signature_help = "(Signature)",
nvim_lua = "(Nvim LSP)",
path = "(Path)",
})[entry.source.name]
return vim_item
end,
},
sources = cmp.config.sources(
{
{
name = "nvim_lsp",
entry_filter = function(entry, context)
local kind = entry:get_kind()
local line = context.cursor_line
local col = context.cursor.col
local char_before_cursor = string.sub(line, col - 1, col - 1)
if char_before_cursor == "." then
if kind == 2 or kind == 5 then
return true
else
return false
end
elseif string.match(line, "^%s*%w*$") then
if kind == 3 or kind == 6 then
return true
else
return false
end
end
return true
end
},
{ name = 'nvim_lua' },
{ name = 'luasnip' },
{ name = 'nvim_lsp_signature_help' },
{ name = 'path' },
{ name = 'orgmode' }
},
{
--This sources will only show up if there aren't any sources from the other list
{ name = "buffer", keyword_length = 5 },
}
),
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = cmp.config.window.bordered(),
completion = cmp.config.window.bordered({
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None"
})
},
experimental = {
ghost_text = true,
native_menu = false,
},
}
end,
},
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason-lspconfig.nvim",
"williamboman/mason.nvim",
},
config = function()
vim.api.nvim_create_augroup("_mason", { clear = true })
require("mason").setup({
PATH = "skip",
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
},
},
max_concurrent_installers = 10,
})
local mason_lspconfig = require "mason-lspconfig"
mason_lspconfig.setup({
ensure_installed = {},
automatic_installation = true
})
local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
-- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, 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', vim.lsp.buf.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() vim.lsp.buf.format { async = true } end, bufopts)
end
local lspconfig = require "lspconfig"
-- ADD NVIM CMP AS A CAPABILITY
local lsp_defaults = lspconfig.util.default_config
local capabilities = vim.tbl_deep_extend(
'force',
lsp_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
)
mason_lspconfig.setup_handlers {
-- This is a default handler that will be called for each installed server (also for new servers that are installed during a session)
function(server_name)
lspconfig[server_name].setup {
on_attach = on_attach,
on_init = on_init,
flags = lsp_flags,
capabilities = capabilities,
}
end,
}
end
}
}

View file

@ -2,12 +2,12 @@ return {
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require('lualine').setup {
require("lualine").setup({
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
component_separators = { left = '|', right = '|' },
section_separators = { left = '', right = '' },
disabled_filetypes = {
statusline = {},
winbar = {},
@ -25,7 +25,7 @@ return {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_x = { 'encoding', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'location' }
},
@ -41,6 +41,6 @@ return {
winbar = {},
inactive_winbar = {},
extensions = {}
}
})
end
}

View file

@ -0,0 +1,17 @@
return {
"nvimtools/none-ls.nvim",
config = function()
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.rustfmt,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.prettierd.with({
filetypes = { "html", "json", "yaml", "markdown" },
}),
}
})
end
}

View file

@ -0,0 +1,14 @@
return {
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim"
},
config = function()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<leader>pg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>gf', builtin.git_files, {})
-- vim.keymap.set('n', '<leader>sb', builtin.buffers, {})
vim.keymap.set('n', '<leader>vh', builtin.help_tags, {})
end
}

View file

@ -0,0 +1,70 @@
return {
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("todo-comments").setup({
signs = true, -- show icons in the signs column
sign_priority = 8, -- sign priority
-- keywords recognized as todo comments
keywords = {
FIX = {
icon = "", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
alt = { "FIXME", "BUG", "FIXIT", "ISSUE", "fix" }, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
TODO = { icon = "", color = "info", alt = { "todo" } },
HACK = { icon = "", color = "warning", alt = { "hack" } },
WARN = { icon = "", color = "warning", alt = { "WARNING", "XXX", "warn" } },
PERF = { icon = "", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE", "perf" } },
NOTE = { icon = "", color = "hint", alt = { "INFO", "info", "note" } },
TEST = { icon = "", color = "test", alt = { "TESTING", "PASSED", "FAILED", "test" } },
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
after = "fg", -- "fg" or "bg" or empty
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
-- list of named colors where we try to extract the guifg from the
-- list of highlight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" }
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
},
})
end
}

View file

@ -0,0 +1,134 @@
return {
{
"nvim-treesitter/nvim-treesitter",
version = false, -- last release is way too old and doesn't work on Windows
build = ":TSUpdate",
init = function(plugin)
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
-- no longer trigger the **nvim-treeitter** module to be loaded in time.
-- Luckily, the only thins that those plugins need are the custom queries, which we make available
-- during startup.
require("lazy.core.loader").add_to_rtp(plugin)
require("nvim-treesitter.query_predicates")
end,
dependencies = {
{
"nvim-treesitter/nvim-treesitter-textobjects",
config = function()
-- When in diff mode, we want to use the default
-- vim text objects c & C instead of the treesitter ones.
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
local configs = require("nvim-treesitter.configs")
for name, fn in pairs(move) do
if name:find("goto") == 1 then
move[name] = function(q, ...)
if vim.wo.diff then
local config = configs.get_module("textobjects.move")
[name] ---@type table<string,string>
for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)
return
end
end
end
return fn(q, ...)
end
end
end
end,
},
},
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
opts = {
highlight = { enable = true },
indent = { enable = true },
ensure_installed = {
"bash",
"c",
"diff",
"html",
"javascript",
"jsdoc",
"json",
"jsonc",
"lua",
"luadoc",
"luap",
"markdown",
"markdown_inline",
"python",
"regex",
"toml",
"vim",
"vimdoc",
"yaml",
"org",
"dockerfile",
"go",
"haskell",
"rust",
},
textobjects = {
move = {
enable = true,
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
},
},
},
config = function(_, opts)
if type(opts.ensure_installed) == "table" then
local added = {}
opts.ensure_installed = vim.tbl_filter(function(lang)
if added[lang] then
return false
end
added[lang] = true
return true
end, opts.ensure_installed)
end
require("nvim-treesitter.configs").setup(opts)
end,
},
{
"romgrk/nvim-treesitter-context",
config = function()
require("treesitter-context").setup({
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
throttle = true, -- Throttles plugin updates (may improve performance)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
show_all_context = false,
patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
-- For all filetypes
-- Note that setting an entry here replaces all other patterns for this entry.
-- By setting the 'default' entry below, you can control which nodes you want to
-- appear in the context window.
default = {
"function",
"method",
"for",
"while",
"if",
"switch",
"case",
},
rust = {
"loop_expression",
"impl_item",
},
typescript = {
"class_declaration",
"abstract_class_declaration",
"else_clause",
},
},
})
end
}
}

View file

@ -25,3 +25,4 @@ vim.keymap.set("v", "<leader>d", "\"_d")
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<leader>s", ":%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>")

View file

@ -42,3 +42,4 @@ vim.opt.shortmess:append("c")
vim.opt.colorcolumn="80"
vim.g.mapleader = " "

View file

@ -49,8 +49,8 @@ local function save_profiles(threshold)
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/tsousa/.cache/nvim/packer_hererocks/2.1.1699392533/share/lua/5.1/?.lua;/home/tsousa/.cache/nvim/packer_hererocks/2.1.1699392533/share/lua/5.1/?/init.lua;/home/tsousa/.cache/nvim/packer_hererocks/2.1.1699392533/lib/luarocks/rocks-5.1/?.lua;/home/tsousa/.cache/nvim/packer_hererocks/2.1.1699392533/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/tsousa/.cache/nvim/packer_hererocks/2.1.1699392533/lib/lua/5.1/?.so"
local package_path_str = "/home/tsousa/.cache/nvim/packer_hererocks/2.1.1702233742/share/lua/5.1/?.lua;/home/tsousa/.cache/nvim/packer_hererocks/2.1.1702233742/share/lua/5.1/?/init.lua;/home/tsousa/.cache/nvim/packer_hererocks/2.1.1702233742/lib/luarocks/rocks-5.1/?.lua;/home/tsousa/.cache/nvim/packer_hererocks/2.1.1702233742/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/tsousa/.cache/nvim/packer_hererocks/2.1.1702233742/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
@ -224,6 +224,11 @@ _G.packer_plugins = {
path = "/home/tsousa/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["todo-comments.nvim"] = {
loaded = true,
path = "/home/tsousa/.local/share/nvim/site/pack/packer/start/todo-comments.nvim",
url = "https://github.com/folke/todo-comments.nvim"
},
undotree = {
loaded = true,
path = "/home/tsousa/.local/share/nvim/site/pack/packer/start/undotree",

View file

@ -1,49 +0,0 @@
return require('packer').startup(function(use)
-- Packer can manage itself
use("nvim-lua/plenary.nvim")
use("nvim-lua/popup.nvim")
use("nvim-telescope/telescope.nvim")
use("tpope/vim-surround")
use("stevearc/dressing.nvim")
use("mbbill/undotree")
-- fidget change when rewrite version comes out
use {
'j-hui/fidget.nvim',
tag = 'legacy',
config = function()
require("fidget").setup {
-- options
}
end,
}
use("norcalli/nvim-colorizer.lua")
use("lervag/vimtex")
use("williamboman/mason.nvim")
use("williamboman/mason-lspconfig.nvim")
use("hrsh7th/cmp-nvim-lsp")
use("neovim/nvim-lspconfig")
use("mfussenegger/nvim-jdtls")
use("jose-elias-alvarez/null-ls.nvim")
use({
"L3MON4D3/LuaSnip",
requires = {
"saadparwaiz1/cmp_luasnip"
},
})
use("nvim-treesitter/nvim-treesitter", {
run = ":TSUpdate"
})
use("nvim-treesitter/playground")
use("romgrk/nvim-treesitter-context")
-- Colorscheme section
use("catppuccin/nvim")
use("ellisonleao/gruvbox.nvim")
end)

View file

@ -1,199 +0,0 @@
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
'hrsh7th/cmp-nvim-lsp', -- lsp
'hrsh7th/cmp-nvim-lua', -- Nvim API completions
'hrsh7th/cmp-nvim-lsp-signature-help', -- Show function signatures
'hrsh7th/cmp-buffer', --buffer completions
'hrsh7th/cmp-path', --path completions
'hrsh7th/cmp-cmdline', --cmdline completions
'L3MON4D3/LuaSnip',
'rafamadriz/friendly-snippets',
'saadparwaiz1/cmp_luasnip',
},
config = function()
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then
return
end
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
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 = "󰊄",
}
-- FIND MORE HERE: HTTPS://WWW.NERDFONTS.COM/CHEAT-SHEET
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
-- Accept currently selected item. If none selected, do nothing.
["<CR>"] = cmp.mapping.confirm { select = false },
["<C-k>"] = cmp.mapping(function(fallback)
if luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end),
["<C-j>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end
),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, {
"i",
"s",
}),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({
nvim_lsp = "(LSP)",
luasnip = "(Snippet)",
buffer = "(Text)",
nvim_lsp_signature_help = "(Signature)",
nvim_lua = "(Nvim LSP)",
path = "(Path)",
})[entry.source.name]
return vim_item
end,
},
sorting = {
comparators = {
cmp.config.compare.exact,
cmp.config.compare.offset,
cmp.config.compare.recently_used,
}
},
sources = cmp.config.sources(
{
{
name = "nvim_lsp",
entry_filter = function(entry, context)
local kind = entry:get_kind()
local line = context.cursor_line
local col = context.cursor.col
local char_before_cursor = string.sub(line, col - 1, col - 1)
if char_before_cursor == "." then
if kind == 2 or kind == 5 then
return true
else
return false
end
elseif string.match(line, "^%s*%w*$") then
if kind == 3 or kind == 6 then
return true
else
return false
end
end
return true
end
},
{ name = 'nvim_lua' },
{ name = 'luasnip' },
{ name = 'nvim_lsp_signature_help' },
{ name = 'path' },
{ name = 'orgmode' }
},
{
--This sources will only show up if there aren't any sources from the other list
{ name = "buffer", keyword_length = 5 },
}
),
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = cmp.config.window.bordered(),
completion = cmp.config.window.bordered({
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None"
})
},
experimental = {
ghost_text = true,
native_menu = false,
},
}
end,
}

View file

@ -1,54 +0,0 @@
require("catppuccin").setup({
flavour = "macchiato", -- latte, frappe, macchiato, mocha
transparent_background = false,
term_colors = false,
no_italic = false, -- Force no italic
no_bold = false, -- Force no bold
styles = {
comments = {"italic"},
conditionals = {"italic"},
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
},
integrations = {
cmp = true,
gitsigns = true,
telescope = true,
},
})
require("gruvbox").setup({
undercurl = true,
underline = true,
bold = true,
italic = {
strings = false,
comments = true,
operators = false,
folds = true,
},
strikethrough = true,
invert_selection = false,
invert_signs = false,
invert_tabline = false,
invert_intend_guides = false,
inverse = true, -- invert background for search, diffs, statuslines and errors
contrast = "", -- can be "hard", "soft" or empty string
palette_overrides = {},
overrides = {},
dim_inactive = false,
transparent_mode = false,
})
vim.o.background = "dark"
vim.cmd.colorscheme("catppuccin")

View file

@ -1,4 +0,0 @@
return {
"j-hui/fidget.nvim",
config = true
}

View file

@ -1,72 +0,0 @@
return {
"neovim/nvim-lspconfig",
dependencies = "williamboman/mason-lspconfig.nvim",
config = function()
local mason_lspconfig = require "mason-lspconfig"
mason_lspconfig.setup({
ensure_installed = {},
automatic_installation = true
})
local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
-- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, 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', vim.lsp.buf.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() vim.lsp.buf.format { async = true } end, bufopts)
end
local lspconfig = require "lspconfig"
-- ADD NVIM CMP AS A CAPABILITY
local lsp_defaults = lspconfig.util.default_config
local capabilities = vim.tbl_deep_extend(
'force',
lsp_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
)
mason_lspconfig.setup_handlers {
-- This is a default handler that will be called for each installed server (also for new servers that are installed during a session)
function(server_name)
lspconfig[server_name].setup {
on_attach = on_attach,
on_init = on_init,
flags = lsp_flags,
capabilities = capabilities,
}
end,
}
end
}

View file

@ -1,19 +0,0 @@
return {
"williamboman/mason.nvim",
config = function()
local present, mason = pcall(require, "mason")
vim.api.nvim_create_augroup("_mason", { clear = true })
options = {
PATH = "skip",
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
},
},
max_concurrent_installers = 10,
}
mason.setup(options)
end
}

View file

@ -1,12 +0,0 @@
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.rustfmt,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.prettierd.with({
filetypes = { "html", "json", "yaml", "markdown" },
}),
}
})

View file

@ -1,13 +0,0 @@
return {
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim"
},
config = function()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>sf', builtin.find_files, {})
vim.keymap.set('n', '<leader>sg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>sb', builtin.buffers, {})
vim.keymap.set('n', '<leader>sh', builtin.help_tags, {})
end
}

View file

@ -1,37 +0,0 @@
return {
"romgrk/nvim-treesitter-context",
config = function()
require("treesitter-context").setup({
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
throttle = true, -- Throttles plugin updates (may improve performance)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
show_all_context = false,
patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
-- For all filetypes
-- Note that setting an entry here replaces all other patterns for this entry.
-- By setting the 'default' entry below, you can control which nodes you want to
-- appear in the context window.
default = {
"function",
"method",
"for",
"while",
"if",
"switch",
"case",
},
rust = {
"loop_expression",
"impl_item",
},
typescript = {
"class_declaration",
"abstract_class_declaration",
"else_clause",
},
},
})
end
}

View file

@ -1,112 +0,0 @@
return {
"nvim-treesitter/nvim-treesitter",
version = false, -- last release is way too old and doesn't work on Windows
build = ":TSUpdate",
event = { "LazyFile", "VeryLazy" },
init = function(plugin)
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
-- no longer trigger the **nvim-treeitter** module to be loaded in time.
-- Luckily, the only thins that those plugins need are the custom queries, which we make available
-- during startup.
require("lazy.core.loader").add_to_rtp(plugin)
require("nvim-treesitter.query_predicates")
end,
dependencies = {
{
"nvim-treesitter/nvim-treesitter-textobjects",
config = function()
-- When in diff mode, we want to use the default
-- vim text objects c & C instead of the treesitter ones.
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
local configs = require("nvim-treesitter.configs")
for name, fn in pairs(move) do
if name:find("goto") == 1 then
move[name] = function(q, ...)
if vim.wo.diff then
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)
return
end
end
end
return fn(q, ...)
end
end
end
end,
},
},
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
keys = {
{ "<c-space>", desc = "Increment selection" },
{ "<bs>", desc = "Decrement selection", mode = "x" },
},
---@type TSConfig
---@diagnostic disable-next-line: missing-fields
opts = {
highlight = { enable = true },
indent = { enable = true },
ensure_installed = {
"bash",
"c",
"diff",
"html",
"javascript",
"jsdoc",
"json",
"jsonc",
"lua",
"luadoc",
"luap",
"markdown",
"markdown_inline",
"python",
"regex",
"toml",
"vim",
"vimdoc",
"yaml",
"org",
"dockerfile",
"go",
"haskell",
"rust",
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
textobjects = {
move = {
enable = true,
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
},
},
},
---@param opts TSConfig
config = function(_, opts)
if type(opts.ensure_installed) == "table" then
---@type table<string, boolean>
local added = {}
opts.ensure_installed = vim.tbl_filter(function(lang)
if added[lang] then
return false
end
added[lang] = true
return true
end, opts.ensure_installed)
end
require("nvim-treesitter.configs").setup(opts)
end,
}