From 4a4997c3ff7cdcfec8ee1366364627106caf8d07 Mon Sep 17 00:00:00 2001 From: Bruno Montezano Date: Tue, 5 Mar 2024 17:17:54 -0300 Subject: [PATCH] Update Neovim config. --- .config/nvim/after/plugin/autopairs.lua | 1 - .config/nvim/after/plugin/catppuccin.lua | 48 ---- .config/nvim/after/plugin/cmp.lua | 26 --- .config/nvim/after/plugin/iron.lua | 49 ----- .config/nvim/after/plugin/lsp.lua | 16 -- .config/nvim/after/plugin/treesitter.lua | 28 --- .config/nvim/after/plugin/vimtex.lua | 1 - .config/nvim/ftplugin/markdown.lua | 2 + .config/nvim/lazy-lock.json | 22 ++ .config/nvim/lua/bruno/lazy.lua | 266 +++++++++++++++++++++-- .config/nvim/lua/bruno/remap.lua | 3 + .config/nvim/lua/bruno/set.lua | 4 + 12 files changed, 278 insertions(+), 188 deletions(-) delete mode 100644 .config/nvim/after/plugin/autopairs.lua delete mode 100644 .config/nvim/after/plugin/catppuccin.lua delete mode 100644 .config/nvim/after/plugin/cmp.lua delete mode 100644 .config/nvim/after/plugin/iron.lua delete mode 100644 .config/nvim/after/plugin/lsp.lua delete mode 100644 .config/nvim/after/plugin/treesitter.lua delete mode 100644 .config/nvim/after/plugin/vimtex.lua create mode 100644 .config/nvim/ftplugin/markdown.lua create mode 100644 .config/nvim/lazy-lock.json diff --git a/.config/nvim/after/plugin/autopairs.lua b/.config/nvim/after/plugin/autopairs.lua deleted file mode 100644 index 7faf5be..0000000 --- a/.config/nvim/after/plugin/autopairs.lua +++ /dev/null @@ -1 +0,0 @@ -require("nvim-autopairs").setup({}) diff --git a/.config/nvim/after/plugin/catppuccin.lua b/.config/nvim/after/plugin/catppuccin.lua deleted file mode 100644 index f940189..0000000 --- a/.config/nvim/after/plugin/catppuccin.lua +++ /dev/null @@ -1,48 +0,0 @@ -require("catppuccin").setup({ - flavour = "mocha", -- latte, frappe, macchiato, mocha - background = { -- :h background - light = "latte", - dark = "mocha", - }, - transparent_background = false, -- disables setting the background color. - show_end_of_buffer = false, -- shows the '~' characters after the end of buffers - term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) - dim_inactive = { - enabled = false, -- dims the background color of inactive window - shade = "dark", - percentage = 0.15, -- percentage of the shade to apply to the inactive window - }, - no_italic = false, -- Force no italic - no_bold = false, -- Force no bold - no_underline = false, -- Force no underline - styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): - comments = { "italic" }, -- Change the style of comments - conditionals = { "italic" }, - loops = {}, - functions = {}, - keywords = {}, - strings = {}, - variables = {}, - numbers = {}, - booleans = {}, - properties = {}, - types = {}, - operators = {}, - }, - color_overrides = {}, - custom_highlights = {}, - integrations = { - cmp = true, - gitsigns = true, - nvimtree = true, - treesitter = true, - notify = false, - mini = { - enabled = true, - indentscope_color = "", - }, - -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) - }, -}) - -vim.cmd.colorscheme "catppuccin" diff --git a/.config/nvim/after/plugin/cmp.lua b/.config/nvim/after/plugin/cmp.lua deleted file mode 100644 index 7c34f81..0000000 --- a/.config/nvim/after/plugin/cmp.lua +++ /dev/null @@ -1,26 +0,0 @@ -local cmp = require('cmp') -local cmp_action = require('lsp-zero').cmp_action() - -cmp.setup({ - mapping = cmp.mapping.preset.insert({ - -- `Enter` key to confirm completion - [''] = cmp.mapping.confirm({select = false}), - - -- Ctrl+Space to trigger completion menu - [''] = cmp.mapping.complete(), - - -- Navigate between snippet placeholder - [''] = cmp_action.luasnip_jump_forward(), - [''] = cmp_action.luasnip_jump_backward(), - - -- Scroll up and down in the completion documentation - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - }), -sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - { name = 'otter' }, - }) -}) diff --git a/.config/nvim/after/plugin/iron.lua b/.config/nvim/after/plugin/iron.lua deleted file mode 100644 index 94d1a64..0000000 --- a/.config/nvim/after/plugin/iron.lua +++ /dev/null @@ -1,49 +0,0 @@ -local iron = require("iron.core") - -iron.setup { - config = { - scratch_repl = true, - repl_definition = { - sh = { - command = {"bash"} - }, - r = { - command = {"R"} - }, - quarto = { - command = {"R"} - }, - python = { - command = {"ipython"} - }, - julia = { - command = {"julia"} - }, - }, - repl_open_cmd = require('iron.view').split.vertical.botright(0.5), - }, - keymaps = { - send_motion = "sc", - visual_send = "sc", - send_file = "sf", - send_line = "sl", - send_until_cursor = "su", - send_mark = "sm", - mark_motion = "mc", - mark_visual = "mc", - remove_mark = "md", - cr = "s", - interrupt = "s", - exit = "sq", - clear = "cl", - }, - highlight = { - italic = true - }, - ignore_blank_lines = true, -} - -vim.keymap.set('n', 'rs', 'IronRepl') -vim.keymap.set('n', 'rr', 'IronRestart') -vim.keymap.set('n', 'rf', 'IronFocus') -vim.keymap.set('n', 'rh', 'IronHide') diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua deleted file mode 100644 index 555cc36..0000000 --- a/.config/nvim/after/plugin/lsp.lua +++ /dev/null @@ -1,16 +0,0 @@ -local lsp_zero = require('lsp-zero') - -lsp_zero.on_attach(function(client, bufnr) - -- see :help lsp-zero-keybindings - -- to learn the available actions - lsp_zero.default_keymaps({ buffer = bufnr }) -end) - -require('mason').setup({}) -require('mason-lspconfig').setup({ - ensure_installed = {}, - handlers = { - lsp_zero.default_setup, - }, - -}) diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua deleted file mode 100644 index 8e05dc7..0000000 --- a/.config/nvim/after/plugin/treesitter.lua +++ /dev/null @@ -1,28 +0,0 @@ -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" (the five listed parsers should always be installed) - ensure_installed = { "c", "lua", "vim", "query", "python", "r", "julia", "html", "css", "bash", "dockerfile", "markdown", "latex", "gitignore" }, - - -- 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, - disable = { "latex" }, - - -- 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, - }, -} diff --git a/.config/nvim/after/plugin/vimtex.lua b/.config/nvim/after/plugin/vimtex.lua deleted file mode 100644 index c3b5804..0000000 --- a/.config/nvim/after/plugin/vimtex.lua +++ /dev/null @@ -1 +0,0 @@ -vim.g.vimtex_view_method = 'zathura' diff --git a/.config/nvim/ftplugin/markdown.lua b/.config/nvim/ftplugin/markdown.lua new file mode 100644 index 0000000..eccf48f --- /dev/null +++ b/.config/nvim/ftplugin/markdown.lua @@ -0,0 +1,2 @@ +vim.opt_local.wrap = true +vim.opt_local.textwidth = 80 diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..52bee8c --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,22 @@ +{ + "LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" }, + "catppuccin": { "branch": "main", "commit": "c0de3b46811fe1ce3912e2245a9dfbea6b41c300" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "iron.nvim": { "branch": "master", "commit": "7f876ee3e1f4ea1e5284b1b697cdad5b256e8046" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "8cce56f62f3b67a44b71106bc687e13e53ff95b0" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "21d33d69a81f6351e5a5f49078b2e4f0075c8e73" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "e270134d83ba59425edc53356c6fd337b61bb8dd" }, + "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, + "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, + "nvim-autopairs": { "branch": "master", "commit": "c6139ca0d5ad7af129ea6c89cb4c56093f2c034a" }, + "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-lspconfig": { "branch": "master", "commit": "7f5cf1121f772850a30bdaf83fb448e88846aa58" }, + "nvim-treesitter": { "branch": "master", "commit": "212b7a504cf56f85d1acc5be237261b42d7560c5" }, + "otter.nvim": { "branch": "main", "commit": "e926e5eeb541d89bfab422083feaaf230a2abf8e" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, + "quarto-nvim": { "branch": "main", "commit": "a6e7452de5944f7f38a4b12f1d50e460c1dccd95" }, + "telescope.nvim": { "branch": "master", "commit": "dc1ea28cc2a02cd1cebb9d80e967807d668f78f8" }, + "vimtex": { "branch": "master", "commit": "a77d14b2e4391c0d3e860708bb1fd56161ab68eb" } +} \ No newline at end of file diff --git a/.config/nvim/lua/bruno/lazy.lua b/.config/nvim/lua/bruno/lazy.lua index 9818ad3..d618bad 100644 --- a/.config/nvim/lua/bruno/lazy.lua +++ b/.config/nvim/lua/bruno/lazy.lua @@ -14,12 +14,15 @@ vim.opt.rtp:prepend(lazypath) vim.g.mapleader = " " local plugins = { - + 'nvim-lua/plenary.nvim', 'quarto-dev/quarto-nvim', { 'windwp/nvim-autopairs', event = 'InsertEnter', - opts = {} + opts = {}, + config = function() + require("nvim-autopairs").setup({}) + end, }, { 'jmbuhr/otter.nvim', @@ -30,26 +33,251 @@ local plugins = { }, }, 'lervag/vimtex', - { 'catppuccin/nvim', name = 'catppuccin' }, - { 'Vigemus/iron.nvim' }, - { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' }, { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v3.x', - dependencies = { - --- Automatic LSP servers - { 'williamboman/mason.nvim' }, - { 'williamboman/mason-lspconfig.nvim' }, - - -- LSP Support - { 'neovim/nvim-lspconfig' }, - -- Autocompletion - { 'hrsh7th/nvim-cmp' }, - { 'hrsh7th/cmp-nvim-lsp' }, - { 'L3MON4D3/LuaSnip' }, - { 'hrsh7th/cmp-path' } + 'catppuccin/nvim', + name = 'catppuccin', + config = function() + require("catppuccin").setup({ + flavour = "latte", -- latte, frappe, macchiato, mocha + background = { + light = "latte", + dark = "mocha", + }, + transparent_background = false, + show_end_of_buffer = false, + term_colors = false, + dim_inactive = { + enabled = false, + shade = "dark", + percentage = 0.15, + }, + no_italic = false, + no_bold = false, + no_underline = false, + styles = { + comments = { "italic" }, + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = {}, + custom_highlights = {}, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + treesitter = true, + notify = false, + mini = { + enabled = true, + indentscope_color = "", + }, + }, + }) + end + }, + { + 'Vigemus/iron.nvim', + config = function() + local iron = require("iron.core") + + iron.setup { + config = { + scratch_repl = true, + repl_definition = { + sh = { + command = { "bash" } + }, + r = { + command = { "R" } + }, + quarto = { + command = { "R" } + }, + python = { + command = { "ipython" } + }, + julia = { + command = { "julia" } + }, + }, + repl_open_cmd = require('iron.view').split.vertical.botright(0.5), + }, + keymaps = { + send_motion = "sc", + visual_send = "sc", + send_file = "sf", + send_line = "sl", + send_until_cursor = "su", + send_mark = "sm", + mark_motion = "mc", + mark_visual = "mc", + remove_mark = "md", + cr = "s", + interrupt = "s", + exit = "sq", + clear = "cl", + }, + highlight = { + italic = true + }, + ignore_blank_lines = true, + } + + vim.keymap.set('n', 'rs', 'IronRepl') + vim.keymap.set('n', 'rr', 'IronRestart') + vim.keymap.set('n', 'rf', 'IronFocus') + vim.keymap.set('n', 'rh', 'IronHide') + end + }, + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function() + require 'nvim-treesitter.configs'.setup { + ensure_installed = { "c", "lua", "vim", "query", "python", "r", "julia", "html", "css", "bash", "dockerfile", "markdown", "latex", "gitignore" }, + sync_install = false, + auto_install = true, + ignore_install = { "javascript" }, + highlight = { + enable = true, + disable = { "latex" }, + additional_vim_regex_highlighting = false, + }, + } + end + }, + { + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + lazy = true, + config = false, + init = function() + -- Disable automatic setup, we are doing it manually + vim.g.lsp_zero_extend_cmp = 0 + vim.g.lsp_zero_extend_lspconfig = 0 + end, + }, + { + 'williamboman/mason.nvim', + lazy = false, + config = true, + }, + -- Autocompletion + { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + { 'L3MON4D3/LuaSnip' }, + { 'hrsh7th/cmp-path' }, + }, + config = function() + -- Here is where you configure the autocompletion settings. + local lsp_zero = require('lsp-zero') + lsp_zero.extend_cmp() + + -- And you can configure cmp even more, if you want to. + local cmp = require('cmp') + local cmp_action = lsp_zero.cmp_action() + + cmp.setup({ + formatting = lsp_zero.cmp_format(), + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.confirm({ select = false }), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp_action.luasnip_jump_forward(), + [''] = cmp_action.luasnip_jump_backward(), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + { name = 'otter' }, + }) + }) + end + }, + -- LSP + { + 'neovim/nvim-lspconfig', + cmd = { 'LspInfo', 'LspInstall', 'LspStart' }, + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + { 'hrsh7th/cmp-nvim-lsp' }, + { 'williamboman/mason-lspconfig.nvim' }, + }, + config = function() + -- This is where all the LSP shenanigans will live + local lsp_zero = require('lsp-zero') + lsp_zero.extend_lspconfig() + + --- if you want to know more about lsp-zero and mason.nvim + --- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md + lsp_zero.on_attach(function(client, bufnr) + -- see :help lsp-zero-keybindings + -- to learn the available actions + lsp_zero.default_keymaps({ buffer = bufnr }) + end) + + require('mason-lspconfig').setup({ + ensure_installed = {}, + handlers = { + lsp_zero.default_setup, + lua_ls = function() + -- (Optional) Configure lua language server for neovim + local lua_opts = lsp_zero.nvim_lua_ls() + require('lspconfig').lua_ls.setup(lua_opts) + end, + } + }) + end } }, + { + "jay-babu/mason-null-ls.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "williamboman/mason.nvim", + { + "jose-elias-alvarez/null-ls.nvim", + config = function() + require("null-ls").setup({ + sources = {} + }) + end + }, + }, + config = function() + require("mason-null-ls").setup({ + ensure_installed = { "black", "clang-format" }, + automatic_installation = false, + handlers = {}, + }) + end + }, + { + "nvim-telescope/telescope.nvim", + lazy = true, + config = function() + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', builtin.find_files, {}) + vim.keymap.set('n', 'fg', builtin.live_grep, {}) + vim.keymap.set('n', 'fb', builtin.buffers, {}) + vim.keymap.set('n', 'fh', builtin.help_tags, {}) + vim.keymap.set('n', 'fc', builtin.colorscheme, {}) + end + }, } require("lazy").setup(plugins, {}) diff --git a/.config/nvim/lua/bruno/remap.lua b/.config/nvim/lua/bruno/remap.lua index 6fcd89f..9fb76a6 100644 --- a/.config/nvim/lua/bruno/remap.lua +++ b/.config/nvim/lua/bruno/remap.lua @@ -21,3 +21,6 @@ vim.keymap.set("v", "d", "\"_d") vim.keymap.set("n", "s", ":%s/\\<\\>//gI") vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) + +vim.keymap.set('n', '[d', function() vim.diagnostic.goto_prev() end) +vim.keymap.set('n', ']d', function() vim.diagnostic.goto_next() end) diff --git a/.config/nvim/lua/bruno/set.lua b/.config/nvim/lua/bruno/set.lua index d85afa8..cc521b1 100644 --- a/.config/nvim/lua/bruno/set.lua +++ b/.config/nvim/lua/bruno/set.lua @@ -32,3 +32,7 @@ vim.opt.splitright = true vim.g.loaded_ruby_provider = 0 vim.g.loaded_perl_provider = 0 + +vim.g.vimtex_view_method = 'zathura' + +vim.cmd.colorscheme "catppuccin"