updates to nvim config

This commit is contained in:
Andre Henriques 2024-12-12 11:48:40 +00:00
parent 677aec9379
commit f70ce6f237
9 changed files with 355 additions and 87 deletions

View File

@ -0,0 +1,7 @@
; extends
((inline) @injection.content
(#lua-match? @injection.content "^%s*import")
(#set! injection.language "typescript"))
((inline) @injection.content
(#lua-match? @injection.content "^%s*export")
(#set! injection.language "typescript"))

View File

@ -1,23 +1,30 @@
{
"ayu-vim": { "branch": "master", "commit": "0745635421688ce777f663d13531996cb4da6514" },
"bubblegum-theme": { "branch": "main", "commit": "105b1302ee54abae9abc199710b94a6098572a8e" },
"cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" },
"cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"fidget": { "branch": "main", "commit": "3a93300c076109d86c7ce35ec67a8034ae6ba9db" },
"friendly-snippets": { "branch": "main", "commit": "69a2c1675b66e002799f5eef803b87a12f593049" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lsp_signature.nvim": { "branch": "master", "commit": "fed2c8389c148ff1dfdcdca63c2b48d08a50dea0" },
"luasnip": { "branch": "master", "commit": "82108e7e31cc6fc223cc5df5cae6d89f70bb199f" },
"neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" },
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
"nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" },
"nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" },
"plenary": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" },
"vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }
"cmp-snippy": { "branch": "master", "commit": "6e39210aa3a74e2bf6462f492eaf0d436cd2b7d3" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"fidget": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" },
"friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" },
"gitsigns.nvim": { "branch": "main", "commit": "ac5aba6dce8c06ea22bea2c9016f51a2dbf90dc7" },
"hererocks": { "branch": "master", "commit": "c9c5444dea1e07e005484014a8231aa667be30b6" },
"lazy.nvim": { "branch": "main", "commit": "56ead98e05bb37a4ec28930a54d836d033cf00f2" },
"lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" },
"luasnip": { "branch": "master", "commit": "0f7bbce41ea152a94d12aea286f2ce98e63c0f58" },
"neogen": { "branch": "main", "commit": "e3b8f6dca1c67c73ae2817418d39c061fdb65064" },
"nvim-cmp": { "branch": "main", "commit": "be7bd4c5f860c79da97af3a26d489af50babfd4b" },
"nvim-lspconfig": { "branch": "master", "commit": "291a8f1a319dc712db85bcc174b0cf406f0a5b69" },
"nvim-snippy": { "branch": "master", "commit": "86a0b645551ca83153a594097ee0267498abaae2" },
"nvim-tree.lua": { "branch": "master", "commit": "db8d7ac1f524fc6f808764b29fa695c51e014aa6" },
"nvim-treesitter": { "branch": "master", "commit": "2d5c122af9c3c842d74a137446dae8ff349206ac" },
"oxocarbon.nvim": { "branch": "main", "commit": "004777819ba294423b638a35a75c9f0c7be758ed" },
"plenary": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"snacks.nvim": { "branch": "main", "commit": "9651a931043359fcc094ab5c67ac22554a602745" },
"telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" },
"trouble.nvim": { "branch": "main", "commit": "3dc00c0447c016cd43e03054c3d49436a1f2076d" },
"undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" },
"vim-fugitive": { "branch": "master", "commit": "320b18fba2a4f2fe3c8225c778c687e0d2620384" }
}

View File

@ -2,6 +2,6 @@
-- vim.g.mapleader = " "
-- vim.g.maplocalleader = " "
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")
-- vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
-- vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")

View File

@ -12,30 +12,60 @@ function setup_attach()
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "gf", function()
vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf(), async = false })
end, { buffer = bufnr, desc = "[lsp] format" })
-- 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>D', vim.lsp.buf.type_definition, opts)
-- vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', 'gf', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})
end
function setup_cmp()
local cmp = require('cmp')
local kind_icons = {
Text = "",
Method = "󰆧",
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)
require('luasnip').lsp_expand(args.body)
-- require('luasnip').lsp_expand(args.body)
require('snippy').expand_snippet(args.body)
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
@ -46,10 +76,28 @@ function setup_cmp()
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'snippy' },
{ name = 'path' },
{ name = 'emoji' },
}, {
{ name = 'buffer' },
})
}),
formatting = {
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatenates the icons with the name of the item kind
-- vim_item.kind = kind_icons[vim_item.kind]
-- Source
vim_item.menu = ({
buffer = "📝",
nvim_lsp = "🔎",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[LaTeX]",
})[entry.source.name]
return vim_item
end
},
})
cmp.setup.cmdline(':', {
@ -81,56 +129,133 @@ return {
'hrsh7th/nvim-cmp',
'saadparwaiz1/cmp_luasnip',
"ray-x/lsp_signature.nvim",
'luasnip',
'dcampos/nvim-snippy',
'dcampos/cmp-snippy',
'fidget',
},
config = function()
local lspconfig = require('lspconfig')
vim.diagnostic.config({
virtual_text = {
prefix = "👈",
},
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "🆒",
[vim.diagnostic.severity.WARN] = "😞",
[vim.diagnostic.severity.HINT] = "🆘",
[vim.diagnostic.severity.INFO] = "🆓",
CodeAction = "🈁",
}
},
})
local lspconfig = require('lspconfig')
-- Check out trouble
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.diagnostic.config({
virtual_text = {
prefix = "👈",
},
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "🆒",
[vim.diagnostic.severity.WARN] = "😞",
[vim.diagnostic.severity.HINT] = "🆘",
[vim.diagnostic.severity.INFO] = "🆓",
CodeAction = "🈁",
}
},
})
setup_attach()
setup_cmp()
-- Check out trouble
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
local capabilities = vim.tbl_deep_extend(
setup_attach()
setup_cmp()
local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
require('cmp_nvim_lsp').default_capabilities()
)
)
local def_set_servers = { "tsserver", "svelte", "zls", "gopls" }
local def_set_servers = { "ts_ls", "svelte", "zls", "gopls", "cssls", "pylsp", "rust_analyzer", "tailwindcss", "dartls", "ols", "jdtls", "biome" }
for _, server_name in ipairs(def_set_servers) do
lspconfig[server_name].setup({
capabilities = capabilities,
})
end
for _, server_name in ipairs(def_set_servers) do
lspconfig[server_name].setup({
capabilities = capabilities,
})
end
lspconfig.elixirls.setup({
cmd = { "elixir-ls" },
capabilities = capabilities,
})
lspconfig.elixirls.setup({
cmd = { "elixir-ls" },
capabilities = capabilities,
})
require("lsp_signature").on_attach({bind = true})
local jdk_home = "/usr/lib/jvm/java-17-openjdk" -- Your actual jdk path
local util = require('lspconfig/util')
lspconfig.kotlin_language_server.setup {
cmd_env = {
PATH = jdk_home .. "/bin:" .. vim.env.PATH,
JAVA_HOME = jdk_home,
},
init_options = {
storagePath = util.path.join(vim.env.XDG_DATA_HOME, "nvim-data"),
},
capabilities = capabilities,
}
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
-- Format the current buffer on save
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = args.buf,
callback = function()
vim.lsp.buf.format({bufnr = args.buf, id = client.id})
end,
})
end
end,
})
end,
},
{
"ray-x/lsp_signature.nvim",
event = "InsertEnter",
opts = {
bind = true,
handler_opts = {
border = "rounded"
}
},
config = function(_, opts) require'lsp_signature'.setup(opts) end
},
{
"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)",
},
},
}
}

View File

@ -3,6 +3,6 @@ return {
dependencies = {"nvim-treesitter/nvim-treesitter"},
config = function()
require('neogen').setup({})
vim.keymap.set("n", "<leader>gc", ":lua require('neogen').generate()<CR>", opts)
vim.keymap.set("n", "<leader>cc", ":lua require('neogen').generate()<CR>", opts)
end,
}

View File

@ -7,6 +7,7 @@ return {
vim.keymap.set('n', '<leader>f', telescope.find_files, {})
vim.keymap.set('n', '<leader>/', telescope.live_grep, {})
vim.keymap.set('n', '<leader>b', telescope.buffers, {})
vim.keymap.set('n', '<leader>g', telescope.git_status, {})
vim.keymap.set('n', '<leader>?', telescope.help_tags, {})
vim.keymap.set('n', '<leader>pws', function()
local word = vim.fn.expand("<cword>")

View File

@ -5,15 +5,59 @@ return {
-- vim.cmd('colorscheme bubblegum-256-light')
-- end
-- },
{
"ayu-theme/ayu-vim",
config = function()
vim.g.ayucolor="dark"
vim.g.indentLine_char = ''
vim.g.indentLine_first_char = ''
vim.g.indentLine_showFirstIndentLevel = 1
vim.g.indentLine_setColors = 0
vim.cmd('colorscheme ayu')
end
},
-- {
-- "ayu-theme/ayu-vim",
-- config = function()
-- vim.g.ayucolor="dark"
-- vim.g.indentLine_char = ''
-- vim.g.indentLine_first_char = ''
-- vim.g.indentLine_showFirstIndentLevel = 1
-- vim.g.indentLine_setColors = 0
-- vim.cmd('colorscheme ayu')
-- end
-- },
-- {
-- "SWilson4/valerie",
-- config = function()
-- vim.cmd('colorscheme valerie')
-- end
-- },
-- {
-- "sts10/vim-pink-moon",
-- config = function()
-- vim.cmd('colorscheme pink-moon')
-- end
-- },
-- {
-- "rose-pine/neovim",
-- config = function()
-- vim.cmd('colorscheme rose-pine-moon')
-- end
-- },
-- {
-- 'ribru17/bamboo.nvim',
-- lazy = false,
-- priority = 1000,
-- config = function()
-- require('bamboo').setup {
-- -- optional configuration here
-- }
-- require('bamboo').load()
-- end,
-- },
-- {
-- "folke/tokyonight.nvim",
-- lazy = false,
-- priority = 1000,
-- config = function()
-- vim.cmd[[colorscheme tokyonight-day]]
-- end
-- }
{
"nyoom-engineering/oxocarbon.nvim",
config = function()
vim.opt.background = "dark" -- set this to dark or light
vim.cmd.colorscheme "oxocarbon"
end
}
}

View File

@ -3,20 +3,94 @@ return {
'nvim-treesitter/nvim-treesitter',
config = function()
local ts_update = require('nvim-treesitter.install').update({ with_sync = true });
ts_update()
require('nvim-treesitter.configs').setup({
ensure_installed = {
"lua", "svelte", "javascript", "typescript", "html", "elixir", "vim",
"jsdoc", "go",
"jsdoc", "go", "css", "scss", "markdown"
},
auto_install = true,
highlight = {
enable = true
}
})
vim.treesitter.language.register('markdown', { 'mdx' })
-- vim.wo.foldmethod = 'expr'
-- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
end
},
{
'lewis6991/gitsigns.nvim',
config = function()
require('gitsigns').setup{
on_attach = function(bufnr)
local gitsigns = require('gitsigns')
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then
vim.cmd.normal({']c', bang = true})
else
gitsigns.nav_hunk('next')
end
end)
map('n', '[c', function()
if vim.wo.diff then
vim.cmd.normal({'[c', bang = true})
else
gitsigns.nav_hunk('prev')
end
end)
map('n', '<leader>hd', gitsigns.diffthis)
end
}
end
},
{
"folke/snacks.nvim",
priority = 1000,
lazy = false,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
bigfile = { enabled = true },
notifier = { enabled = true },
-- quickfile = { enabled = true },
-- statuscolumn = { enabled = true },
-- words = { enabled = true },
},
},
{
"nvim-tree/nvim-tree.lua",
config = function()
require("nvim-tree").setup({
sort = {
sorter = "case_sensitive",
},
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
})
local api = require "nvim-tree.api"
vim.keymap.set('n', '<C-b>', function() api.tree.toggle() end)
end
}
-- {
-- 'wellle/context.vim',
-- }
}

View File

@ -13,7 +13,17 @@ vim.opt.smartindent = true
vim.opt.wrap = true
vim.opt.clipboard = "unnamedplus"
vim.opt.signcolumn = "number"
-- vim.opt.signcolumn = "number"
vim.opt.signcolumn = "yes"
vim.opt.termguicolors = true
vim.opt.cursorline = true
-- vim.opt.foldenable = false
-- vim.opt.foldmethod = "indent"
vim.filetype.add({
extension = {
mdx = 'mdx'
}
})