From ddd950c246a2af8bbaa8a692f175dc6316aee2ba Mon Sep 17 00:00:00 2001 From: victor-cb Date: Wed, 23 Oct 2024 10:17:32 -0300 Subject: [PATCH] working neovim --- init.lua | 213 +++++++++++++++++++++++++++++++------------------ lazy-lock.json | 9 +++ 2 files changed, 143 insertions(+), 79 deletions(-) diff --git a/init.lua b/init.lua index ea86b792..fdf60ccc 100644 --- a/init.lua +++ b/init.lua @@ -1,87 +1,13 @@ --[[ - -===================================================================== -==================== 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! :) + `:help`. --]] -- Set as the leader key @@ -91,7 +17,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` @@ -230,7 +156,6 @@ vim.opt.rtp:prepend(lazypath) require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically - -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following -- keys can be used to configure plugin behavior/loading/etc. @@ -258,6 +183,58 @@ require('lazy').setup({ -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- + + { + 'rust-lang/rust.vim', + ft = 'rust', + init = function() + vim.g.rustfmt_autosave = 1 + end, + }, + + { + 'mfussenegger/nvim-dap', + config = function() + local dap, dapui = require 'dap', require 'dapui' + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.dapui_config = function() + dapui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + dapui.close() + end + end, + }, + + { + 'rcarriga/nvim-dap-ui', + dependencies = { 'mfussenegger/nvim-dap', 'nvim-neotest/nvim-nio' }, + config = function() + require('dapui').setup() + end, + }, + + { + 'saecki/crates.nvim', + ft = { 'toml' }, + config = function() + require('crates').setup { + completion = { + cmp = { + enabled = true, + }, + }, + } + require('cmp').setup.buffer { + sources = { { name = 'crates' } }, + } + end, + }, -- This is often very useful to both group configuration, as well as handle -- lazy loading plugins that don't need to be loaded immediately at startup. -- @@ -266,11 +243,21 @@ require('lazy').setup({ -- -- which loads which-key before all the UI elements are loaded. Events can be -- normal autocommands events (`:help autocmd-events`). - -- + { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function + }, -- Then, because we use the `config` key, the configuration only runs -- after the plugin has been loaded: -- config = function() ... end - + { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, + }, { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' @@ -453,7 +440,16 @@ require('lazy').setup({ { 'Bilal2453/luvit-meta', lazy = true }, { -- Main LSP Configuration + 'neovim/nvim-lspconfig', + opts = { + setup = { + rust_analyzer = function() + return true + end, + }, + }, + dependencies = { -- Automatically install LSPs and related tools to stdpath for Neovim { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants @@ -534,7 +530,32 @@ require('lazy').setup({ -- Fuzzy find all the symbols in your current workspace. -- Similar to document symbols, except searches over your entire project. map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + -- + --mapping debugger for rust + local map_key = vim.keymap.set + map_key('n', ';', ':', { desc = 'CMD enter command mode' }) + map_key('i', 'jk', '') + + -- map({ "n", "i", "v" }, "", " w ") + + -- Nvim DAP + map_key('n', 'dl', "lua require'dap'.step_into()", { desc = 'Debugger step into' }) + map_key('n', 'dj', "lua require'dap'.step_over()", { desc = 'Debugger step over' }) + map_key('n', 'dk', "lua require'dap'.step_out()", { desc = 'Debugger step out' }) + map_key('n', 'dc', "lua require'dap'.continue()", { desc = 'Debugger continue' }) + map_key('n', 'db', "lua require'dap'.toggle_breakpoint()", { desc = 'Debugger toggle breakpoint' }) + map_key( + 'n', + 'dd', + "lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))", + { desc = 'Debugger set conditional breakpoint' } + ) + map_key('n', 'de', "lua require'dap'.terminate()", { desc = 'Debugger reset' }) + map_key('n', 'dr', "lua require'dap'.run_last()", { desc = 'Debugger run last' }) + + -- rustaceanvim + map_key('n', 'dt', "lua vim.cmd('RustLsp testables')", { desc = 'Debugger testables' }) -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. map('rn', vim.lsp.buf.rename, '[R]e[n]ame') @@ -954,3 +975,37 @@ require('lazy').setup({ -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +-- +local harpoon = require 'harpoon' + +-- REQUIRED +harpoon:setup() +-- REQUIRED + +vim.keymap.set('n', 'a', function() + harpoon:list():add() +end) +vim.keymap.set('n', '', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) +end) + +vim.keymap.set('n', '', function() + harpoon:list():select(1) +end) +vim.keymap.set('n', '', function() + harpoon:list():select(2) +end) +vim.keymap.set('n', '', function() + harpoon:list():select(3) +end) +vim.keymap.set('n', '', function() + harpoon:list():select(4) +end) + +-- Toggle previous & next buffers stored within Harpoon list +vim.keymap.set('n', '', function() + harpoon:list():prev() +end) +vim.keymap.set('n', '', function() + harpoon:list():next() +end) diff --git a/lazy-lock.json b/lazy-lock.json index 0d81ded4..08f4fc8e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -4,8 +4,10 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform.nvim": { "branch": "master", "commit": "f5bd8419f8a29451e20bdb1061a54fe13d5c8de3" }, + "crates.nvim": { "branch": "main", "commit": "8bf8358ee326d5d8c11dcd7ac0bcc9ff97dbc785" }, "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "gitsigns.nvim": { "branch": "main", "commit": "ee7634ab4f0a6606438fe13e16cbf2065589a5ed" }, + "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, "lazy.nvim": { "branch": "main", "commit": "1159bdccd8910a0fd0914b24d6c3d186689023d9" }, "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, @@ -13,10 +15,17 @@ "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mini.nvim": { "branch": "main", "commit": "8d94201fece82559881362da80063a4842b6c4c4" }, + "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, "nvim-cmp": { "branch": "main", "commit": "88661b7cbff086a43b3a3d173b09d0f753d7391d" }, + "nvim-dap": { "branch": "master", "commit": "7ff6936010b7222fea2caea0f67ed77f1b7c60dd" }, + "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, "nvim-lspconfig": { "branch": "master", "commit": "84f867753f659bfd9319f75bd5eb273a315f2da5" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-treesitter": { "branch": "master", "commit": "df20c049694474021cffb2cc8687c809adc1cbba" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, + "rustaceanvim": { "branch": "master", "commit": "6eb1c41463a0ad02a4fe799321cc7f651b87e576" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },