From cb546c06da143c7cb6c695a0d10dee68ad99413e Mon Sep 17 00:00:00 2001 From: Andre Raposo Date: Tue, 16 Jul 2024 10:20:18 -0300 Subject: [PATCH] Refactor setup and refork --- init.lua | 183 ++++++++---------------- lua/custom/plugins/fugitive.lua | 3 + lua/custom/plugins/mini-jump.lua | 5 + lua/custom/plugins/ts-autotag.lua | 14 ++ lua/custom/plugins/typescript-tools.lua | 5 + lua/custom/plugins/venv-selector.lua | 13 ++ lua/custom/plugins/vim-test.lua | 41 ++++++ lua/kickstart/plugins/indent_line.lua | 26 ++++ lua/kickstart/plugins/neo-tree.lua | 4 +- 9 files changed, 172 insertions(+), 122 deletions(-) create mode 100644 lua/custom/plugins/fugitive.lua create mode 100644 lua/custom/plugins/mini-jump.lua create mode 100644 lua/custom/plugins/ts-autotag.lua create mode 100644 lua/custom/plugins/typescript-tools.lua create mode 100644 lua/custom/plugins/venv-selector.lua create mode 100644 lua/custom/plugins/vim-test.lua diff --git a/init.lua b/init.lua index 4eae8e7d..e231e918 100644 --- a/init.lua +++ b/init.lua @@ -1,89 +1,3 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) @@ -91,7 +5,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,7 +16,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -154,7 +68,7 @@ vim.opt.inccommand = 'split' vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. -vim.opt.scrolloff = 10 +vim.opt.scrolloff = 25 -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -246,11 +160,12 @@ require('lazy').setup({ 'lewis6991/gitsigns.nvim', opts = { signs = { - add = { text = '+' }, - change = { text = '~' }, + add = { text = '┃' }, + change = { text = '┃' }, delete = { text = '_' }, topdelete = { text = '‾' }, changedelete = { text = '~' }, + untracked = { text = '┆' }, }, }, }, @@ -317,7 +232,7 @@ require('lazy').setup({ spec = { { 'c', group = '[C]ode', mode = { 'n', 'x' } }, { 'd', group = '[D]ocument' }, - { 'r', group = '[R]ename' }, + { 'r', group = '[R]un' }, { 's', group = '[S]earch' }, { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, @@ -355,7 +270,7 @@ require('lazy').setup({ { 'nvim-telescope/telescope-ui-select.nvim' }, -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.havedescnerd_font }, }, config = function() -- Telescope is a fuzzy finder that comes with a lot of different things that @@ -538,7 +453,7 @@ require('lazy').setup({ -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. - map('rn', vim.lsp.buf.rename, '[R]e[n]ame') + map('cr', vim.lsp.buf.rename, '[C]ode [R]ename') -- Execute a code action, usually your cursor needs to be on top of an error -- or a suggestion from your LSP for this to activate. @@ -618,7 +533,20 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = { + settings = { + pyright = { autoImportCompletion = true }, + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = 'openFilesOnly', + useLibraryCodeForTypes = true, + typeCheckingMode = 'off', + }, + }, + }, + }, + jedi_language_server = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -643,6 +571,8 @@ require('lazy').setup({ }, }, }, + -- Zig + -- zls = {}, } -- Ensure the servers and tools above are installed @@ -661,6 +591,10 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'black', -- Used to format python code + 'sonarlint-language-server', -- Helpful linting and diagnostics + 'css-lsp', -- css + 'emmet-language-server', -- emmet }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -694,7 +628,7 @@ require('lazy').setup({ }, }, opts = { - notify_on_error = false, + notify_on_error = true, format_on_save = function(bufnr) -- Disable "format_on_save lsp_fallback" for languages that don't -- have a well standardized coding style. You can add additional @@ -714,10 +648,20 @@ require('lazy').setup({ formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, + python = { 'isort', 'black' }, -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, + -- You can use a sub-list to tell conform to run *until* a formatter + -- is found. + javascript = { { 'prettierd', 'prettier' } }, + javascriptreact = { { 'prettierd', 'prettier' } }, + typescript = { { 'prettierd', 'prettier' } }, + typescriptreact = { { 'prettierd', 'prettier' } }, + css = { { 'prettierd', 'prettier' } }, + scss = { { 'prettierd', 'prettier' } }, + json = { { 'prettierd', 'prettier' } }, + graphql = { { 'prettierd', 'prettier' } }, + markdown = { { 'prettierd', 'prettier' } }, + yaml = { { 'prettierd', 'prettier' } }, }, }, }, @@ -742,12 +686,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -757,6 +701,9 @@ require('lazy').setup({ -- into multiple repos for maintenance purposes. 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/nvim-cmp', }, config = function() -- See `:help cmp` @@ -793,9 +740,9 @@ require('lazy').setup({ -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display @@ -931,23 +878,19 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, - -- - -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` - -- Or use telescope! - -- In normal mode type `sh` then write `lazy.nvim-plugin` - -- you can continue same window with `sr` which resumes last telescope search + -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/fugitive.lua b/lua/custom/plugins/fugitive.lua new file mode 100644 index 00000000..b6b4c97b --- /dev/null +++ b/lua/custom/plugins/fugitive.lua @@ -0,0 +1,3 @@ +return { + 'tpope/vim-fugitive', +} diff --git a/lua/custom/plugins/mini-jump.lua b/lua/custom/plugins/mini-jump.lua new file mode 100644 index 00000000..9a9565bd --- /dev/null +++ b/lua/custom/plugins/mini-jump.lua @@ -0,0 +1,5 @@ +return { + 'echasnovski/mini.jump', + version = '*', + opts = {}, +} diff --git a/lua/custom/plugins/ts-autotag.lua b/lua/custom/plugins/ts-autotag.lua new file mode 100644 index 00000000..f6dbd28c --- /dev/null +++ b/lua/custom/plugins/ts-autotag.lua @@ -0,0 +1,14 @@ +return { + { + 'windwp/nvim-ts-autotag', + event = 'VeryLazy', + opts = { + autotag = { + enable = true, + enable_rename = true, + enable_close = true, + enable_close_on_slash = false, + }, + }, + }, +} diff --git a/lua/custom/plugins/typescript-tools.lua b/lua/custom/plugins/typescript-tools.lua new file mode 100644 index 00000000..ba7fb204 --- /dev/null +++ b/lua/custom/plugins/typescript-tools.lua @@ -0,0 +1,5 @@ +return { + 'pmizio/typescript-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, + opts = {}, +} diff --git a/lua/custom/plugins/venv-selector.lua b/lua/custom/plugins/venv-selector.lua new file mode 100644 index 00000000..45f03e9c --- /dev/null +++ b/lua/custom/plugins/venv-selector.lua @@ -0,0 +1,13 @@ +return { + 'linux-cultist/venv-selector.nvim', + dependencies = { + 'neovim/nvim-lspconfig', + 'mfussenegger/nvim-dap', + 'mfussenegger/nvim-dap-python', --optional + }, + lazy = false, + branch = 'regexp', -- This is the regexp branch, use this for the new version + config = function() + require('venv-selector').setup() + end, +} diff --git a/lua/custom/plugins/vim-test.lua b/lua/custom/plugins/vim-test.lua new file mode 100644 index 00000000..30051e86 --- /dev/null +++ b/lua/custom/plugins/vim-test.lua @@ -0,0 +1,41 @@ +return { + 'vim-test/vim-test', + opts = {}, + keys = { + { + 'rt', + function() + vim.cmd.TestNearest() + end, + desc = '[R]un nearest', + }, + { + 'rT', + function() + vim.cmd.TestFile() + end, + desc = '[R]un file', + }, + { + 'rs', + function() + vim.cmd.TestSuite() + end, + desc = '[R]un [S]uite', + }, + { + 'rl', + function() + vim.cmd.TestLast() + end, + desc = '[R]un [L]ast', + }, + { + 'rv', + function() + vim.cmd.TestVisit() + end, + desc = '[R]un [V]isit', + }, + }, +} diff --git a/lua/kickstart/plugins/indent_line.lua b/lua/kickstart/plugins/indent_line.lua index ed7f2693..c28713c2 100644 --- a/lua/kickstart/plugins/indent_line.lua +++ b/lua/kickstart/plugins/indent_line.lua @@ -4,6 +4,32 @@ return { -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help ibl` main = 'ibl', + config = function() + local highlight = { + 'RainbowRed', + 'RainbowYellow', + 'RainbowBlue', + 'RainbowOrange', + 'RainbowGreen', + 'RainbowViolet', + 'RainbowCyan', + } + + local hooks = require 'ibl.hooks' + -- create the highlight groups in the highlight setup hook, so they are reset + -- every time the colorscheme changes + hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + vim.api.nvim_set_hl(0, 'RainbowRed', { fg = '#E06C75' }) + vim.api.nvim_set_hl(0, 'RainbowYellow', { fg = '#E5C07B' }) + vim.api.nvim_set_hl(0, 'RainbowBlue', { fg = '#61AFEF' }) + vim.api.nvim_set_hl(0, 'RainbowOrange', { fg = '#D19A66' }) + vim.api.nvim_set_hl(0, 'RainbowGreen', { fg = '#98C379' }) + vim.api.nvim_set_hl(0, 'RainbowViolet', { fg = '#C678DD' }) + vim.api.nvim_set_hl(0, 'RainbowCyan', { fg = '#56B6C2' }) + end) + + require('ibl').setup { indent = { highlight = highlight } } + end, opts = {}, }, } diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index bd442269..1bd11c6f 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -11,13 +11,13 @@ return { }, cmd = 'Neotree', keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, + { '~', ':Neotree reveal', { desc = 'NeoTree reveal' } }, }, opts = { filesystem = { window = { mappings = { - ['\\'] = 'close_window', + ['~'] = 'close_window', }, }, },