From 1a7dacc199ead1aa1d52242a7d83d63d85984060 Mon Sep 17 00:00:00 2001 From: Andre Raposo Date: Tue, 6 Aug 2024 14:39:54 -0300 Subject: [PATCH] Refactors for tests, debug and neotree --- init.lua | 91 ++++++++++++++++++------------ lua/custom/plugins/copilot.lua | 13 +++++ lua/custom/plugins/lualine.lua | 29 ++++++++++ lua/custom/plugins/noice.lua | 27 +++++++++ lua/custom/plugins/trouble.lua | 47 +++++++++++++++ lua/custom/plugins/vim-test.lua | 7 ++- lua/custom/plugins/vimtex.lua | 5 ++ lua/custom/plugins/wilder.lua | 12 ++++ lua/custom/plugins/zen-mode.lua | 6 ++ lua/kickstart/plugins/debug.lua | 90 ++++++++++++++++++++++++++--- lua/kickstart/plugins/gitsigns.lua | 24 ++++++++ lua/kickstart/plugins/neo-tree.lua | 29 ++++++++++ 12 files changed, 335 insertions(+), 45 deletions(-) create mode 100644 lua/custom/plugins/copilot.lua create mode 100644 lua/custom/plugins/lualine.lua create mode 100644 lua/custom/plugins/noice.lua create mode 100644 lua/custom/plugins/trouble.lua create mode 100644 lua/custom/plugins/vimtex.lua create mode 100644 lua/custom/plugins/wilder.lua create mode 100644 lua/custom/plugins/zen-mode.lua diff --git a/init.lua b/init.lua index e231e918..8b6d63f6 100644 --- a/init.lua +++ b/init.lua @@ -7,6 +7,9 @@ vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal vim.g.have_nerd_font = true +-- Set global theme +vim.g.theme = 'oxocarbon' + -- [[ Setting options ]] -- See `:help vim.opt` -- NOTE: You can change these options as you wish! @@ -139,6 +142,7 @@ vim.opt.rtp:prepend(lazypath) -- To update plugins you can run -- :Lazy update -- +-- -- NOTE: Here is where you install your plugins. require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). @@ -158,16 +162,7 @@ require('lazy').setup({ -- See `:help gitsigns` to understand what the configuration keys do { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '┃' }, - change = { text = '┃' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - untracked = { text = '┆' }, - }, - }, + opts = {}, }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. @@ -592,9 +587,11 @@ require('lazy').setup({ vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code 'black', -- Used to format python code - 'sonarlint-language-server', -- Helpful linting and diagnostics + 'debugpy', -- Python Debugger 'css-lsp', -- css 'emmet-language-server', -- emmet + 'sonarlint-language-server', -- Helpful linting and diagnostics + 'markdownlint', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -792,17 +789,35 @@ require('lazy').setup({ -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. 'folke/tokyonight.nvim', priority = 1000, -- Make sure to load this before all the other start plugins. - init = function() - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' - - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' + -- init = function() + -- -- Load the colorscheme here. + -- -- Like many other themes, this one has different styles, and you could load + -- -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. + -- vim.cmd.colorscheme 'tokyonight-night' + -- + -- -- You can configure highlights by doing something like: + -- vim.cmd.hi 'Comment gui=none' + -- end, + }, + { + 'Mofiqul/adwaita.nvim', + lazy = false, + priority = 1000, + config = function() + vim.cmd.colorscheme(vim.g.theme) end, }, - + { + 'uloco/bluloco.nvim', + lazy = false, + priority = 1000, + dependencies = { 'rktjmp/lush.nvim' }, + }, + { + 'nyoom-engineering/oxocarbon.nvim', + lazy = false, + priority = 1000, + }, -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, @@ -824,21 +839,7 @@ require('lazy').setup({ -- - sr)' - [S]urround [R]eplace [)] ['] require('mini.surround').setup() - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we set the section for - -- cursor location to LINE:COLUMN - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end - + require('mini.icons').setup() -- ... and there is more! -- Check out: https://github.com/echasnovski/mini.nvim end, @@ -849,7 +850,22 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'javascript', + 'typescript', + 'jsdoc', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -913,5 +929,8 @@ require('lazy').setup({ }, }) +-- Setup python provider +vim.g.python3_host_prog = '$HOME/.asdf/shims/python' + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..0869a0a1 --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,13 @@ +return { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + build = ':Copilot auth', + opts = { + suggestion = { enabled = false }, + panel = { enabled = false }, + filetypes = { + markdown = true, + help = true, + }, + }, +} diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 00000000..19ccd391 --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,29 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = { + options = { + icons_enabled = vim.g.have_nerd_font, + theme = 'auto', + + -- Sections + section_separators = '', + component_separators = '|', + }, + sections = { + lualine_a = { 'branch', { 'diff', colored = false } }, + lualine_b = { { 'diagnostics', sources = { 'nvim_diagnostic' } } }, + lualine_c = { { 'filename', file_status = true, newfile_status = true, path = 0 } }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { + { + require('noice').api.status.mode.get, + cond = require('noice').api.status.mode.has, + color = { fg = '#ff9e64' }, + }, + 'mode', + }, + lualine_z = { 'location' }, + }, + }, +} diff --git a/lua/custom/plugins/noice.lua b/lua/custom/plugins/noice.lua new file mode 100644 index 00000000..6bd22f80 --- /dev/null +++ b/lua/custom/plugins/noice.lua @@ -0,0 +1,27 @@ +return { + 'folke/noice.nvim', + event = 'VeryLazy', + opts = { + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp + }, + }, + -- you can enable a preset for easier configuration + cmdline = { + view = 'cmdline', + }, + presets = { + long_message_to_split = false, -- long messages will be sent to a split + inc_rename = true, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + }, + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + 'MunifTanjim/nui.nvim', + }, +} diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 00000000..02983b1b --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,47 @@ +return { + 'folke/trouble.nvim', + cmd = { 'Trouble' }, + opts = { + modes = { + lsp = { + win = { position = 'right' }, + }, + }, + }, + keys = { + { 'xx', 'Trouble diagnostics toggle', desc = 'Diagnostics (Trouble)' }, + { 'xX', 'Trouble diagnostics toggle filter.buf=0', desc = 'Buffer Diagnostics (Trouble)' }, + { 'cs', 'Trouble symbols toggle', desc = 'Symbols (Trouble)' }, + { 'cS', 'Trouble lsp toggle', desc = 'LSP references/definitions/... (Trouble)' }, + { 'xL', 'Trouble loclist toggle', desc = 'Location List (Trouble)' }, + { 'xQ', 'Trouble qflist toggle', desc = 'Quickfix List (Trouble)' }, + { + '[q', + function() + if require('trouble').is_open() then + require('trouble').prev { skip_groups = true, jump = true } + else + local ok, err = pcall(vim.cmd.cprev) + if not ok then + vim.notify(err, vim.log.levels.ERROR) + end + end + end, + desc = 'Previous Trouble/Quickfix Item', + }, + { + ']q', + function() + if require('trouble').is_open() then + require('trouble').next { skip_groups = true, jump = true } + else + local ok, err = pcall(vim.cmd.cnext) + if not ok then + vim.notify(err, vim.log.levels.ERROR) + end + end + end, + desc = 'Next Trouble/Quickfix Item', + }, + }, +} diff --git a/lua/custom/plugins/vim-test.lua b/lua/custom/plugins/vim-test.lua index 30051e86..990d9fde 100644 --- a/lua/custom/plugins/vim-test.lua +++ b/lua/custom/plugins/vim-test.lua @@ -1,6 +1,11 @@ return { 'vim-test/vim-test', - opts = {}, + lazy = false, + config = function() + require('which-key').add { + { 'r', name = '[R]un tests', desc = 'which_key_ignore' }, + } + end, keys = { { 'rt', diff --git a/lua/custom/plugins/vimtex.lua b/lua/custom/plugins/vimtex.lua new file mode 100644 index 00000000..84db24f5 --- /dev/null +++ b/lua/custom/plugins/vimtex.lua @@ -0,0 +1,5 @@ +return { + 'lervag/vimtex', + lazy = false, + opt = {}, +} diff --git a/lua/custom/plugins/wilder.lua b/lua/custom/plugins/wilder.lua new file mode 100644 index 00000000..b5ee5a7e --- /dev/null +++ b/lua/custom/plugins/wilder.lua @@ -0,0 +1,12 @@ +-- if true then +-- return {} +-- end + +return { + 'gelguy/wilder.nvim', + opts = {}, + config = function() + local wilder = require 'wilder' + wilder.setup { modes = { ':', '/', '?' } } + end, +} diff --git a/lua/custom/plugins/zen-mode.lua b/lua/custom/plugins/zen-mode.lua new file mode 100644 index 00000000..f4352fdf --- /dev/null +++ b/lua/custom/plugins/zen-mode.lua @@ -0,0 +1,6 @@ +return { + 'folke/zen-mode.nvim', + opts = { + -- pass + }, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 753cb0ce..41d48c69 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -22,7 +22,60 @@ return { 'jay-babu/mason-nvim-dap.nvim', -- Add your own debuggers here - 'leoluz/nvim-dap-go', + 'mfussenegger/nvim-dap-python', + }, + keys = { + -- Basic debugging keymaps, feel free to change to your liking! + { + '', + function() + require('dap').continue() + end, + desc = 'Debug: Start/Continue', + }, + { + '', + function() + require('dap').step_into() + end, + desc = 'Debug: Step Into', + }, + { + '', + function() + require('dap').step_over() + end, + desc = 'Debug: Step Over', + }, + { + '', + function() + require('dap').step_out() + end, + desc = 'Debug: Step Out', + }, + { + 'b', + function() + require('dap').toggle_breakpoint() + end, + desc = 'Debug: Toggle Breakpoint', + }, + { + 'B', + function() + require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, + desc = 'Debug: Set Breakpoint', + }, + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + { + '', + function() + require('dapui').toggle() + end, + desc = 'Debug: See last session result.', + }, }, keys = { -- Basic debugging keymaps, feel free to change to your liking! @@ -94,7 +147,7 @@ return { -- online, please don't ask me how to install them :) ensure_installed = { -- Update this to ensure that you have the debuggers for the langs you want - 'delve', + 'debugpy', }, } @@ -120,6 +173,27 @@ return { }, } + -- Change breakpoint icons + -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) + -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) + -- local breakpoint_icons = vim.g.have_nerd_font + -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } + -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } + -- for type, icon in pairs(breakpoint_icons) do + -- local tp = 'Dap' .. type + -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' + -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) + -- end + -- Basic debugging keymaps, feel free to change to your liking! + vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) + vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) + vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) + vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) + vim.keymap.set('n', 'B', function() + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, { desc = 'Debug: Set Breakpoint' }) + -- Change breakpoint icons -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) @@ -136,12 +210,12 @@ return { dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close - -- Install golang specific config - require('dap-go').setup { - delve = { - -- On Windows delve must be run attached or it crashes. - -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring - detached = vim.fn.has 'win32' == 0, + dap.configurations.python = { + { + type = 'python', + request = 'launch', + name = 'Launch file', + program = '${file}', }, } end, diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua index c269bc06..c06f6d96 100644 --- a/lua/kickstart/plugins/gitsigns.lua +++ b/lua/kickstart/plugins/gitsigns.lua @@ -6,6 +6,30 @@ return { { 'lewis6991/gitsigns.nvim', opts = { + current_line_blame = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 300, + ignore_whitespace = false, + virt_text_priority = 100, + }, + + signs = { + add = { text = '┃ ' }, + change = { text = '┃ ' }, + delete = { text = '' }, + topdelete = { text = '' }, + changedelete = { text = '▎' }, + untracked = { text = '▎' }, + }, + signs_staged = { + add = { text = '▎' }, + change = { text = '▎' }, + delete = { text = '' }, + topdelete = { text = '' }, + changedelete = { text = '▎' }, + }, on_attach = function(bufnr) local gitsigns = require 'gitsigns' diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index 1bd11c6f..cb2e1b81 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -8,6 +8,7 @@ return { 'nvim-lua/plenary.nvim', 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended 'MunifTanjim/nui.nvim', + '3rd/image.nvim', }, cmd = 'Neotree', keys = { @@ -21,5 +22,33 @@ return { }, }, }, + default_component_configs = { + name = { + trailing_slash = true, + use_git_status_colors = true, + highlight = 'NeoTreeFileName', + }, + git_status = { + symbols = { + -- Change type + added = '✚', -- or "✚", but this is redundant info if you use git_status_colors on the name + modified = '', -- or "", but this is redundant info if you use git_status_colors on the name + deleted = '✖', -- this can only be used in the git_status source + renamed = '󰁕', -- this can only be used in the git_status source + -- Status type + untracked = '', + ignored = '', + unstaged = '󰄱', + staged = '', + conflict = '', + }, + }, + indent = { + with_expanders = true, -- if nil and file nesting is enabled, will enable expanders + expander_collapsed = '', + expander_expanded = '', + expander_highlight = 'NeoTreeExpander', + }, + }, }, }