Guest User

my nvim config

a guest
Aug 14th, 2025
14
0
4 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 31.39 KB | None | 0 0
  1. -- Set <space> as the leader key
  2. --  NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
  3. vim.g.mapleader = " "
  4. vim.g.maplocalleader = " "
  5.  
  6. -- Set to true if you have a Nerd Font installed and selected in the terminal
  7. vim.g.have_nerd_font = true
  8.  
  9. -- [[ Setting options ]]
  10. -- See `:help vim.opt`
  11. --  For more options, you can see `:help option-list`
  12.  
  13. vim.opt.number = true
  14. vim.opt.relativenumber = true
  15. vim.opt.showmode = false
  16. -- osclip=vimclip
  17. vim.opt.clipboard = "unnamedplus"
  18. -- ignore case except if cap in phrase
  19. vim.opt.ignorecase = true
  20. vim.opt.smartcase = true
  21. -- Enable break indent
  22. vim.opt.breakindent = true
  23. -- Save undo history
  24. vim.opt.undofile = true
  25. -- Keep signcolumn on by default
  26. vim.opt.signcolumn = "yes"
  27. -- Decrease update time
  28. vim.opt.updatetime = 250
  29. -- Decrease mapped sequence wait time
  30. -- Displays which-key popup sooner
  31. vim.opt.timeoutlen = 300
  32. -- Configure how new splits should be opened
  33. vim.opt.splitright = true
  34. vim.opt.splitbelow = true
  35. -- Sets how neovim will display certain whitespace characters in the editor.
  36. --  See `:help 'list'`
  37. --  and `:help 'listchars'`
  38. vim.opt.list = true
  39. vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
  40. -- Preview substitutions live, as you type!
  41. vim.opt.inccommand = "split"
  42. -- Show which line your cursor is on
  43. vim.opt.cursorline = true
  44. -- Minimal number of screen lines to keep above and below the cursor.
  45. vim.opt.scrolloff = 8
  46.  
  47. local function yank_whole_file()
  48.     vim.cmd("normal! gg0vG$y")
  49. end
  50. -- [[ Macros ]]
  51. vim.keymap.set("n", "<leader>yy", yank_whole_file, { noremap = true, silent = true })
  52.  
  53. -- [[ Basic Keymaps ]]
  54. --  See `:help vim.keymap.set()`
  55. -- Set highlight on search, but clear on pressing <Esc> in normal mode
  56. vim.opt.hlsearch = true
  57. vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
  58. vim.keymap.set("n", ";", ":")
  59. vim.keymap.set("n", "<C-e>", "<cmd>e .<CR>")
  60. vim.keymap.set("n", "<C-s>", "<cmd>w<CR>")
  61. vim.keymap.set("i", "<C-s>", "<cmd>w<CR>")
  62.  
  63. -- [[barbar Keymaps]]
  64. vim.keymap.set("n", "<Tab>", ":BufferNext<CR>", { silent = true })
  65. vim.keymap.set("n", "<S-Tab>", ":BufferPrevious<CR>", { silent = true })
  66. vim.keymap.set("n", "<C-S-Left>", ":BufferMovePrevious<CR>", { silent = true })
  67. vim.keymap.set("n", "<C-S-Right>", ":BufferMoveNext<CR>", { silent = true })
  68. vim.keymap.set("n", "<C-S-h>", ":BufferMovePrevious<CR>", { silent = true })
  69. vim.keymap.set("n", "<C-S-l>", ":BufferMoveNext<CR>", { silent = true })
  70. vim.keymap.set("n", "<A-1>", ":BufferGoto 1<CR>", { silent = true })
  71. vim.keymap.set("n", "<A-2>", ":BufferGoto 2<CR>", { silent = true })
  72. vim.keymap.set("n", "<A-3>", ":BufferGoto 3<CR>", { silent = true })
  73. vim.keymap.set("n", "<A-4>", ":BufferGoto 4<CR>", { silent = true })
  74. vim.keymap.set("n", "<A-5>", ":BufferGoto 5<CR>", { silent = true })
  75. vim.keymap.set("n", "<A-6>", ":BufferGoto 6<CR>", { silent = true })
  76. vim.keymap.set("n", "<A-7>", ":BufferGoto 7<CR>", { silent = true })
  77. vim.keymap.set("n", "<A-8>", ":BufferGoto 8<CR>", { silent = true })
  78. vim.keymap.set("n", "<A-9>", ":BufferGoto 9<CR>", { silent = true })
  79. vim.keymap.set("n", "<A-0>", ":BufferLast<CR>", { silent = true })
  80. vim.keymap.set("n", "<Leader>x", ":BufferClose<CR>", { silent = true })
  81.  
  82. -- Diagnostic keymaps
  83. vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous [D]iagnostic message" })
  84. vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next [D]iagnostic message" })
  85. vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" })
  86. vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
  87. vim.keymap.set("i", "<C-BS>", "<C-w>", { desc = "Delete previous word" })
  88.  
  89. -- Keybinds to make split navigation easier.
  90. --  Use CTRL+<hjkl> to switch between windows
  91. --  See `:help wincmd` for a list of all window commands
  92. vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
  93. vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
  94. vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
  95. vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
  96.  
  97. -- [[ Basic Autocommands ]]
  98. --  See `:help lua-guide-autocommands`
  99. vim.api.nvim_create_autocmd("TextYankPost", {
  100.     desc = "Highlight when yanking (copying) text",
  101.     group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }),
  102.     callback = function()
  103.         vim.highlight.on_yank()
  104.     end,
  105. })
  106. vim.api.nvim_create_autocmd("FileType", {
  107.     pattern = "haskell",
  108.     callback = function()
  109.         vim.opt_local.expandtab = true
  110.         vim.opt_local.shiftwidth = 4
  111.         vim.opt_local.tabstop = 4
  112.     end,
  113. })
  114.  
  115. -- [[ Install `lazy.nvim` plugin manager ]]
  116. --    See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
  117. local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
  118. if not vim.loop.fs_stat(lazypath) then
  119.     local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  120.     vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
  121. end ---@diagnostic disable-next-line: undefined-field
  122. vim.opt.rtp:prepend(lazypath)
  123.  
  124. -- [[ Configure and install plugins ]]
  125. --
  126. --  To check the current status of your plugins, run
  127. --    :Lazy
  128. --
  129. --  You can press `?` in this menu for help. Use `:q` to close the window
  130. --
  131. --  To update plugins you can run
  132. --    :Lazy update
  133. --
  134.  
  135. require("lazy").setup({
  136.     "tpope/vim-sleuth", -- Detect tabstop and shiftwidth automatically
  137.  
  138.     {
  139.         "linux-cultist/venv-selector.nvim",
  140.         dependecies = {
  141.             "neovim/nvim-lspconfig",
  142.             "nvim-telescope/telescope.nvim",
  143.             "mfussenegger/nvim-dap-python",
  144.         },
  145.         opts = {
  146.             name = "venv",
  147.         },
  148.         keys = {
  149.             -- Keymap to open VenvSelector to pick a venv.
  150.             { "<leader>vs", "<cmd>VenvSelect<cr>" },
  151.             -- Keymap to retrieve the venv from a cache (the one previously used for the same project directory).
  152.             { "<leader>vc", "<cmd>VenvSelectCached<cr>" },
  153.         },
  154.     },
  155.  
  156.     {
  157.         "romgrk/barbar.nvim",
  158.         dependecies = {
  159.             "kyazdani42/nvim-web-devicons",
  160.         },
  161.     },
  162.  
  163.     {
  164.         "stevearc/oil.nvim",
  165.         opts = {
  166.             columns = {
  167.                 "icon",
  168.                 "size",
  169.                 "mtime",
  170.             },
  171.             keymaps = { -- Defaults
  172.                 ["g?"] = "actions.show_help",
  173.                 ["<CR>"] = "actions.select",
  174.                 ["<C-s>"] = "actions.select_vsplit",
  175.                 ["<C-h>"] = "actions.select_split",
  176.                 ["<C-t>"] = "actions.select_tab",
  177.                 ["<C-p>"] = "actions.preview",
  178.                 ["<C-c>"] = "actions.close",
  179.                 ["<C-l>"] = "actions.refresh",
  180.                 ["-"] = "actions.parent",
  181.                 ["_"] = "actions.open_cwd",
  182.                 ["`"] = "actions.cd",
  183.                 ["~"] = "actions.tcd",
  184.                 ["gs"] = "actions.change_sort",
  185.                 ["gx"] = "actions.open_external",
  186.                 ["g."] = "actions.toggle_hidden",
  187.                 ["g\\"] = "actions.toggle_trash",
  188.             },
  189.             delete_to_trash = true,
  190.         },
  191.         -- nvim oil-ssh://[username@]hostname[:port]/[path] for SSH open buffer using this
  192.         dependencies = { "nvim-tree/nvim-web-devicons" },
  193.     },
  194.  
  195.     { "MunifTanjim/nui.nvim" },
  196.  
  197.     -- Use `opts = {}` to force a plugin to be loaded.
  198.     --
  199.     --  This is equivalent to:
  200.     --    require('Comment').setup({})
  201.  
  202.     -- "gc" to comment visual regions/lines
  203.     { "numToStr/Comment.nvim", opts = {} },
  204.  
  205.     -- Here is a more advanced example where we pass configuration
  206.     -- options to `gitsigns.nvim`. This is equivalent to the following Lua:
  207.     --    require('gitsigns').setup({ ... })
  208.     --
  209.     -- See `:help gitsigns` to understand what the configuration keys do
  210.     { -- Adds git related signs to the gutter, as well as utilities for managing changes
  211.         "lewis6991/gitsigns.nvim",
  212.         opts = {
  213.             signs = {
  214.                 add = { text = "+" },
  215.                 change = { text = "~" },
  216.                 delete = { text = "_" },
  217.                 topdelete = { text = "‾" },
  218.                 changedelete = { text = "~" },
  219.             },
  220.         },
  221.     },
  222.  
  223.     -- NOTE: Plugins can also be configured to run Lua code when they are loaded.
  224.     --
  225.     -- This is often very useful to both group configuration, as well as handle
  226.     -- lazy loading plugins that don't need to be loaded immediately at startup.
  227.     --
  228.     -- For example, in the following configuration, we use:
  229.     --  event = 'VimEnter'
  230.     --
  231.     -- which loads which-key before all the UI elements are loaded. Events can be
  232.     -- normal autocommands events (`:help autocmd-events`).
  233.     --
  234.     -- Then, because we use the `config` key, the configuration only runs
  235.     -- after the plugin has been loaded:
  236.     --  config = function() ... end
  237.  
  238.     { -- Useful plugin to show you pending keybinds.
  239.         "folke/which-key.nvim",
  240.         event = "VimEnter", -- Sets the loading event to 'VimEnter'
  241.         config = function() -- This is the function that runs, AFTER loading
  242.             require("which-key").setup()
  243.  
  244.             -- Document existing key chains
  245.             require("which-key").register({
  246.                 ["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" },
  247.                 ["<leader>d"] = { name = "[D]ocument", _ = "which_key_ignore" },
  248.                 ["<leader>r"] = { name = "[R]ename", _ = "which_key_ignore" },
  249.                 ["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
  250.                 ["<leader>w"] = { name = "[W]orkspace", _ = "which_key_ignore" },
  251.                 ["<leader>t"] = { name = "[T]oggle", _ = "which_key_ignore" },
  252.                 ["<leader>h"] = { name = "Git [H]unk", _ = "which_key_ignore" },
  253.             })
  254.             -- visual mode
  255.             require("which-key").register({
  256.                 ["<leader>h"] = { "Git [H]unk" },
  257.             }, { mode = "v" })
  258.         end,
  259.     },
  260.  
  261.     -- The dependencies are proper plugin specifications as well - anything
  262.     -- you do for a plugin at the top level, you can do for a dependency.
  263.     --
  264.     -- Use the `dependencies` key to specify the dependencies of a particular plugin
  265.  
  266.     { -- Fuzzy Finder (files, lsp, etc)
  267.         "nvim-telescope/telescope.nvim",
  268.         event = "VimEnter",
  269.         branch = "0.1.x",
  270.         dependencies = {
  271.             "nvim-lua/plenary.nvim",
  272.             { -- If encountering errors, see telescope-fzf-native README for installation instructions
  273.                 "nvim-telescope/telescope-fzf-native.nvim",
  274.  
  275.                 -- `build` is used to run some command when the plugin is installed/updated.
  276.                 -- This is only run then, not every time Neovim starts up.
  277.                 build = "make",
  278.  
  279.                 -- `cond` is a condition used to determine whether this plugin should be
  280.                 -- installed and loaded.
  281.                 cond = function()
  282.                     return vim.fn.executable("make") == 1
  283.                 end,
  284.             },
  285.             { "nvim-telescope/telescope-ui-select.nvim" },
  286.  
  287.             -- Useful for getting pretty icons, but requires a Nerd Font.
  288.             { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font },
  289.         },
  290.         config = function()
  291.             -- The easiest way to use Telescope, is to start by doing something like:
  292.             --  :Telescope help_tags
  293.             --
  294.             -- After running this command, a window will open up and you're able to
  295.             -- type in the prompt window. You'll see a list of `help_tags` options and
  296.             -- a corresponding preview of the help.
  297.             --
  298.             -- This opens a window that shows you all of the keymaps for the current
  299.             -- Telescope picker. This is really useful to discover what Telescope can
  300.             -- do as well as how to actually do it!
  301.  
  302.             -- [[ Configure Telescope ]]
  303.             -- See `:help telescope` and `:help telescope.setup()`
  304.             require("telescope").setup({
  305.                 -- You can put your default mappings / updates / etc. in here
  306.                 --  All the info you're looking for is in `:help telescope.setup()`
  307.                 --
  308.                 -- defaults = {
  309.                 --   mappings = {
  310.                 --     i = { ['<c-enter>'] = 'to_fuzzy_refine' },
  311.                 --   },
  312.                 -- },
  313.                 -- pickers = {}
  314.                 extensions = {
  315.                     ["ui-select"] = {
  316.                         require("telescope.themes").get_dropdown(),
  317.                     },
  318.                 },
  319.             })
  320.  
  321.             -- Enable Telescope extensions if they are installed
  322.             pcall(require("telescope").load_extension, "fzf")
  323.             pcall(require("telescope").load_extension, "ui-select")
  324.  
  325.             -- See `:help telescope.builtin`
  326.             local builtin = require("telescope.builtin")
  327.             vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp" })
  328.             vim.keymap.set("n", "<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
  329.             vim.keymap.set("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
  330.             vim.keymap.set("n", "<leader>ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" })
  331.             vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
  332.             vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
  333.             vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
  334.             vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
  335.             vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
  336.             vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
  337.  
  338.             -- Slightly advanced example of overriding default behavior and theme
  339.             vim.keymap.set("n", "<leader>/", function()
  340.                 -- You can pass additional configuration to Telescope to change the theme, layout, etc.
  341.                 builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
  342.                     winblend = 10,
  343.                     previewer = false,
  344.                 }))
  345.             end, { desc = "[/] Fuzzily search in current buffer" })
  346.  
  347.             -- It's also possible to pass additional configuration options.
  348.             --  See `:help telescope.builtin.live_grep()` for information about particular keys
  349.             vim.keymap.set("n", "<leader>s/", function()
  350.                 builtin.live_grep({
  351.                     grep_open_files = true,
  352.                     prompt_title = "Live Grep in Open Files",
  353.                 })
  354.             end, { desc = "[S]earch [/] in Open Files" })
  355.  
  356.             -- Shortcut for searching your Neovim configuration files
  357.             vim.keymap.set("n", "<leader>sn", function()
  358.                 builtin.find_files({ cwd = vim.fn.stdpath("config") })
  359.             end, { desc = "[S]earch [N]eovim files" })
  360.         end,
  361.     },
  362.  
  363.     { -- LSP Configuration & Plugins
  364.         "neovim/nvim-lspconfig",
  365.         dependencies = {
  366.             -- Automatically install LSPs and related tools to stdpath for Neovim
  367.             { "williamboman/mason.nvim", config = true }, -- NOTE: Must be loaded before dependants
  368.             "williamboman/mason-lspconfig.nvim",
  369.             "WhoIsSethDaniel/mason-tool-installer.nvim",
  370.  
  371.             -- Useful status updates for LSP.
  372.             -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
  373.             { "j-hui/fidget.nvim", opts = {} },
  374.  
  375.             -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
  376.             -- used for completion, annotations and signatures of Neovim apis
  377.             { "folke/neodev.nvim", opts = {} },
  378.         },
  379.         config = function()
  380.             vim.api.nvim_create_autocmd("LspAttach", {
  381.                 group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
  382.                 callback = function(event)
  383.                     -- NOTE: Remember that Lua is a real programming language, and as such it is possible
  384.                     -- to define small helper and utility functions so you don't have to repeat yourself.
  385.                     --
  386.                     -- In this case, we create a function that lets us more easily define mappings specific
  387.                     -- for LSP related items. It sets the mode, buffer and description for us each time.
  388.                     local map = function(keys, func, desc)
  389.                         vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
  390.                     end
  391.  
  392.                     map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
  393.                     map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
  394.                     map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
  395.  
  396.                     -- Jump to the type of the word under your cursor.
  397.                     map("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition")
  398.  
  399.                     -- Fuzzy find all the symbols in your current document.
  400.                     --  Symbols are things like variables, functions, types, etc.
  401.                     map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
  402.  
  403.                     -- Fuzzy find all the symbols in your current workspace.
  404.                     --  Similar to document symbols, except searches over your entire project.
  405.                     map(
  406.                         "<leader>ws",
  407.                         require("telescope.builtin").lsp_dynamic_workspace_symbols,
  408.                         "[W]orkspace [S]ymbols"
  409.                     )
  410.  
  411.                     -- Rename the variable under your cursor.
  412.                     --  Most Language Servers support renaming across files, etc.
  413.                     map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
  414.  
  415.                     -- Execute a code action, usually your cursor needs to be on top of an error
  416.                     -- or a suggestion from your LSP for this to activate.
  417.                     map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
  418.  
  419.                     -- Opens a popup that displays documentation about the word under your cursor
  420.                     --  See `:help K` for why this keymap.
  421.                     map("K", vim.lsp.buf.hover, "Hover Documentation")
  422.  
  423.                     -- WARN: This is not Goto Definition, this is Goto Declaration.
  424.                     --  For example, in C this would take you to the header.
  425.                     map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
  426.  
  427.                     -- The following two autocommands are used to highlight references of the
  428.                     -- word under your cursor when your cursor rests there for a little while.
  429.                     --    See `:help CursorHold` for information about when this is executed
  430.                     --
  431.                     -- When you move your cursor, the highlights will be cleared (the second autocommand).
  432.                     local client = vim.lsp.get_client_by_id(event.data.client_id)
  433.                     if client and client.server_capabilities.documentHighlightProvider then
  434.                         local highlight_augroup =
  435.                             vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
  436.                         vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
  437.                             buffer = event.buf,
  438.                             group = highlight_augroup,
  439.                             callback = vim.lsp.buf.document_highlight,
  440.                         })
  441.  
  442.                         vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
  443.                             buffer = event.buf,
  444.                             group = highlight_augroup,
  445.                             callback = vim.lsp.buf.clear_references,
  446.                         })
  447.  
  448.                         vim.api.nvim_create_autocmd("LspDetach", {
  449.                             group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
  450.                             callback = function(event2)
  451.                                 vim.lsp.buf.clear_references()
  452.                                 vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
  453.                             end,
  454.                         })
  455.                     end
  456.  
  457.                     -- The following autocommand is used to enable inlay hints in your
  458.                     -- code, if the language server you are using supports them
  459.                     --
  460.                     -- This may be unwanted, since they displace some of your code
  461.                     if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
  462.                         map("<leader>th", function()
  463.                             vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
  464.                         end, "[T]oggle Inlay [H]ints")
  465.                     end
  466.                 end,
  467.             })
  468.  
  469.             -- LSP servers and clients are able to communicate to each other what features they support.
  470.             --  By default, Neovim doesn't support everything that is in the LSP specification.
  471.             --  When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
  472.             --  So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
  473.             local capabilities = vim.lsp.protocol.make_client_capabilities()
  474.             capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
  475.  
  476.             -- Enable the following language servers
  477.             --  Feel free to add/remove any LSPs that you want here. They will automatically be installed.
  478.             --
  479.             --  Add any additional override configuration in the following tables. Available keys are:
  480.             --  - cmd (table): Override the default command used to start the server
  481.             --  - filetypes (table): Override the default list of associated filetypes for the server
  482.             --  - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
  483.             --  - settings (table): Override the default settings passed when initializing the server.
  484.             --        For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
  485.             require("mason-registry")
  486.             local servers = {
  487.                 clangd = {},
  488.                 gopls = {},
  489.                 -- hls = {},
  490.                 -- rust_analyzer = {},
  491.                 -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
  492.                 --
  493.                 -- volar = {},
  494.  
  495.                 lua_ls = {
  496.                     -- cmd = {...},
  497.                     -- filetypes = { ...},
  498.                     -- capabilities = {},
  499.                     settings = {
  500.                         Lua = {
  501.                             completion = {
  502.                                 callSnippet = "Replace",
  503.                             },
  504.                             -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
  505.                             diagnostics = { -- disable = { 'missing-fields' }
  506.                                 globals = { "vim" },
  507.                             },
  508.                         },
  509.                     },
  510.                 },
  511.             }
  512.  
  513.             require("mason").setup()
  514.  
  515.             -- You can add other tools here that you want Mason to install
  516.             -- for you, so that they are available from within Neovim.
  517.             local ensure_installed = vim.tbl_keys(servers or {})
  518.             vim.list_extend(ensure_installed, {
  519.                 "stylua", -- Used to format Lua code
  520.             })
  521.             require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
  522.  
  523.             require("mason-lspconfig").setup({
  524.                 handlers = {
  525.                     function(server_name)
  526.                         local server = servers[server_name] or {}
  527.                         -- This handles overriding only values explicitly passed
  528.                         -- by the server configuration above. Useful when disabling
  529.                         -- certain features of an LSP (for example, turning off formatting for tsserver)
  530.                         server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
  531.                         require("lspconfig")[server_name].setup(server)
  532.                     end,
  533.                 },
  534.             })
  535.         end,
  536.     },
  537.  
  538.     { -- Autoformat
  539.         "stevearc/conform.nvim",
  540.         lazy = false,
  541.         keys = {
  542.             {
  543.                 "<leader>f",
  544.                 function()
  545.                     require("conform").format({ async = true, lsp_fallback = true })
  546.                 end,
  547.                 mode = "",
  548.                 desc = "[F]ormat buffer",
  549.             },
  550.         },
  551.         opts = {
  552.             notify_on_error = false,
  553.             format_on_save = function(bufnr)
  554.                 -- Disable "format_on_save lsp_fallback" for languages that don't
  555.                 -- have a well standardized coding style. You can add additional
  556.                 -- languages here or re-enable it for the disabled ones.
  557.                 local disable_filetypes = { c = true, cpp = true }
  558.                 return {
  559.                     timeout_ms = 500,
  560.                     lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
  561.                 }
  562.             end,
  563.             formatters_by_ft = {
  564.                 lua = { "stylua" },
  565.                 -- Conform can also run multiple formatters sequentially
  566.                 -- python = { "isort", "black" },
  567.                 --
  568.                 -- You can use a sub-list to tell conform to run *until* a formatter
  569.                 -- is found.
  570.                 -- javascript = { { "prettierd", "prettier" } },
  571.             },
  572.         },
  573.     },
  574.  
  575.     { -- Autocompletion
  576.         "hrsh7th/nvim-cmp",
  577.         event = "InsertEnter",
  578.         dependencies = {
  579.             -- Snippet Engine & its associated nvim-cmp source
  580.             {
  581.                 "L3MON4D3/LuaSnip",
  582.                 build = (function()
  583.                     -- Build Step is needed for regex support in snippets.
  584.                     -- This step is not supported in many windows environments.
  585.                     -- Remove the below condition to re-enable on windows.
  586.                     if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
  587.                         return
  588.                     end
  589.                     return "make install_jsregexp"
  590.                 end)(),
  591.                 dependencies = {
  592.                     -- `friendly-snippets` contains a variety of premade snippets.
  593.                     --    See the README about individual language/framework/plugin snippets:
  594.                     --    https://github.com/rafamadriz/friendly-snippets
  595.                     -- {
  596.                     --   'rafamadriz/friendly-snippets',
  597.                     --   config = function()
  598.                     --     require('luasnip.loaders.from_vscode').lazy_load()
  599.                     --   end,
  600.                     -- },
  601.                 },
  602.             },
  603.             "saadparwaiz1/cmp_luasnip",
  604.  
  605.             -- Adds other completion capabilities.
  606.             --  nvim-cmp does not ship with all sources by default. They are split
  607.             --  into multiple repos for maintenance purposes.
  608.             "hrsh7th/cmp-nvim-lsp",
  609.             "hrsh7th/cmp-path",
  610.         },
  611.         config = function()
  612.             -- See `:help cmp`
  613.             local cmp = require("cmp")
  614.             local luasnip = require("luasnip")
  615.             luasnip.config.setup({})
  616.  
  617.             cmp.setup({
  618.                 snippet = {
  619.                     expand = function(args)
  620.                         luasnip.lsp_expand(args.body)
  621.                     end,
  622.                 },
  623.                 completion = { completeopt = "menu,menuone,noinsert" },
  624.  
  625.                 -- For an understanding of why these mappings were
  626.                 -- chosen, you will need to read `:help ins-completion`
  627.                 --
  628.                 -- No, but seriously. Please read `:help ins-completion`, it is really good!
  629.                 mapping = cmp.mapping.preset.insert({
  630.                     -- Select the [n]ext item
  631.                     ["<C-n>"] = cmp.mapping.select_next_item(),
  632.                     -- Select the [p]revious item
  633.                     ["<C-p>"] = cmp.mapping.select_prev_item(),
  634.  
  635.                     -- Scroll the documentation window [b]ack / [f]orward
  636.                     ["<C-b>"] = cmp.mapping.scroll_docs(-4),
  637.                     ["<C-f>"] = cmp.mapping.scroll_docs(4),
  638.  
  639.                     -- Accept ([y]es) the completion.
  640.                     --  This will auto-import if your LSP supports it.
  641.                     --  This will expand snippets if the LSP sent a snippet.
  642.                     ["<C-y>"] = cmp.mapping.confirm({ select = true }),
  643.  
  644.                     -- If you prefer more traditional completion keymaps,
  645.                     -- you can uncomment the following lines
  646.                     --['<CR>'] = cmp.mapping.confirm { select = true },
  647.                     ["<Tab>"] = cmp.mapping.select_next_item(),
  648.                     ["<S-Tab>"] = cmp.mapping.select_prev_item(),
  649.  
  650.                     -- Manually trigger a completion from nvim-cmp.
  651.                     --  Generally you don't need this, because nvim-cmp will display
  652.                     --  completions whenever it has completion options available.
  653.                     ["<C-Space>"] = cmp.mapping.complete({}),
  654.  
  655.                     -- Think of <c-l> as moving to the right of your snippet expansion.
  656.                     --  So if you have a snippet that's like:
  657.                     --  function $name($args)
  658.                     --    $body
  659.                     --  end
  660.                     --
  661.                     -- <c-l> will move you to the right of each of the expansion locations.
  662.                     -- <c-h> is similar, except moving you backwards.
  663.                     ["<C-l>"] = cmp.mapping(function()
  664.                         if luasnip.expand_or_locally_jumpable() then
  665.                             luasnip.expand_or_jump()
  666.                         end
  667.                     end, { "i", "s" }),
  668.                     ["<C-h>"] = cmp.mapping(function()
  669.                         if luasnip.locally_jumpable(-1) then
  670.                             luasnip.jump(-1)
  671.                         end
  672.                     end, { "i", "s" }),
  673.  
  674.                     -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
  675.                     --    https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
  676.                 }),
  677.                 sources = {
  678.                     { name = "nvim_lsp" },
  679.                     { name = "luasnip" },
  680.                     { name = "path" },
  681.                 },
  682.             })
  683.         end,
  684.     },
  685.  
  686.     { -- You can easily change to a different colorscheme.
  687.         -- Change the name of the colorscheme plugin below, and then
  688.         -- change the command in the config to whatever the name of that colorscheme is.
  689.         --
  690.         -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
  691.         "neanias/everforest-nvim",
  692.         lazy = false,
  693.         priority = 1000, -- Make sure to load this before all the other start plugins.
  694.         init = function()
  695.             -- Load the colorscheme here.
  696.             vim.cmd.colorscheme("everforest")
  697.             -- You can configure highlights by doing something like:
  698.             vim.cmd.hi("Comment gui=none")
  699.         end,
  700.     },
  701.  
  702.     -- Highlight todo, notes, etc in comments
  703.     {
  704.         "folke/todo-comments.nvim",
  705.         event = "VimEnter",
  706.         dependencies = { "nvim-lua/plenary.nvim" },
  707.         opts = { signs = false },
  708.     },
  709.  
  710.     { -- Collection of various small independent plugins/modules
  711.         "echasnovski/mini.nvim",
  712.         config = function()
  713.             -- Better Around/Inside textobjects
  714.             --
  715.             -- Examples:
  716.             --  - va)  - [V]isually select [A]round [)]paren
  717.             --  - yinq - [Y]ank [I]nside [N]ext [']quote
  718.             --  - ci'  - [C]hange [I]nside [']quote
  719.             require("mini.ai").setup({ n_lines = 500 })
  720.  
  721.             -- Add/delete/replace surroundings (brackets, quotes, etc.)
  722.             --
  723.             -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
  724.             -- - sd'   - [S]urround [D]elete [']quotes
  725.             -- - sr)'  - [S]urround [R]eplace [)] [']
  726.             require("mini.surround").setup()
  727.  
  728.             -- Simple and easy statusline.
  729.             --  You could remove this setup call if you don't like it,
  730.             --  and try some other statusline plugin
  731.             local statusline = require("mini.statusline")
  732.             -- set use_icons to true if you have a Nerd Font
  733.             statusline.setup({ use_icons = vim.g.have_nerd_font })
  734.  
  735.             -- You can configure sections in the statusline by overriding their
  736.             -- default behavior. For example, here we set the section for
  737.             -- cursor location to LINE:COLUMN
  738.             ---@diagnostic disable-next-line: duplicate-set-field
  739.             statusline.section_location = function()
  740.                 return "%2l:%-2v"
  741.             end
  742.  
  743.             -- ... and there is more!
  744.             --  Check out: https://github.com/echasnovski/mini.nvim
  745.         end,
  746.     },
  747.     { -- Highlight, edit, and navigate code
  748.         "nvim-treesitter/nvim-treesitter",
  749.         build = ":TSUpdate",
  750.         opts = {
  751.             ensure_installed = { "bash", "c", "diff", "html", "lua", "luadoc", "markdown", "vim", "vimdoc" },
  752.             -- Autoinstall languages that are not installed
  753.             auto_install = true,
  754.             highlight = {
  755.                 enable = true,
  756.                 -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
  757.                 --  If you are experiencing weird indenting issues, add the language to
  758.                 --  the list of additional_vim_regex_highlighting and disabled languages for indent.
  759.                 additional_vim_regex_highlighting = { "ruby" },
  760.             },
  761.             indent = { enable = true, disable = { "ruby" } },
  762.         },
  763.         config = function(_, opts)
  764.             -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
  765.  
  766.             -- Prefer git instead of curl in order to improve connectivity in some environments
  767.             require("nvim-treesitter.install").prefer_git = true
  768.             ---@diagnostic disable-next-line: missing-fields
  769.             require("nvim-treesitter.configs").setup(opts)
  770.  
  771.             -- There are additional nvim-treesitter modules that you can use to interact
  772.             -- with nvim-treesitter. You should go explore a few and see what interests you:
  773.             --
  774.             --    - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
  775.             --    - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
  776.             --    - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
  777.         end,
  778.     },
  779.  
  780.     -- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
  781.     -- init.lua. If you want these files, they are in the repository, so you can just download them and
  782.     -- place them in the correct locations.
  783.  
  784.     -- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for Kickstart
  785.     --  Here are some example plugins that I've included in the Kickstart repository.
  786.     --  Uncomment any of the lines below to enable them (you will need to restart nvim).
  787.     --
  788.     -- require 'kickstart.plugins.debug',
  789.     -- require 'kickstart.plugins.indent_line',
  790.     -- require 'kickstart.plugins.lint',
  791.     -- require 'kickstart.plugins.autopairs',
  792.     -- require("kickstart.plugins.neo-tree"),
  793.     -- require("kickstart.plugins.gitsigns"), -- adds gitsigns recommend keymaps
  794.  
  795.     -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
  796.     --    This is the easiest way to modularize your config.
  797.     --
  798.     --  Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
  799.     --    For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
  800.     -- { import = 'custom.plugins' },
  801. }, {
  802.     ui = {
  803.         -- If you are using a Nerd Font: set icons to an empty table which will use the
  804.         -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
  805.         icons = vim.g.have_nerd_font and {} or {
  806.             cmd = "⌘",
  807.             config = "🛠",
  808.             event = "📅",
  809.             ft = "📂",
  810.             init = "⚙",
  811.             keys = "🗝",
  812.             plugin = "🔌",
  813.             runtime = "💻",
  814.             require = "🌙",
  815.             source = "📄",
  816.             start = "🚀",
  817.             task = "📌",
  818.             lazy = "💤 ",
  819.         },
  820.     },
  821. })
  822.  
  823. -- The line beneath this is called `modeline`. See `:help modeline`
  824. -- vim: ts=2 sts=2 sw=2 et
Advertisement
Add Comment
Please, Sign In to add comment