DEV Community

Cover image for My Neovim setup for Mac for coding (in Go), writing and boosting your productivity in 2024
charly3pins
charly3pins

Posted on • Originally published at charly3pins.dev on

My Neovim setup for Mac for coding (in Go), writing and boosting your productivity in 2024

Introduction

I'm not going to lie, I tried to jump from my editor to Vim many times since I was using Eclipse, then Sublime and the latest VS Code.
I have always been fascinated with Vim and its potential. How something so simple can be so powerful? The reality is that I started several times the Vimtutor and I got stuck.
I tried to edit the text in Vim and I got stuck. I tried to code something and I got stuck. Last year I tried seriously and I spent one or two weeks just using Vim.
I thought it was the moment, but I failed... again. In Q2 this year I decided to take that seriously. I read a lot of posts, watched a few YouTube videos and I also read
Mastering Vim Quickly: From WTF to OMG in no time by Jovica Ilic. Now yes! I am using Vim for almost anything. Sometimes I have to admit
that I'm still using VS Code for tasks that require editing a lot of lines at the same time and I'm still not that good with Vim, but very little.

So today I'm gonna show you my configuration of Neovim and all the plugins that I use every day while coding mainly.

Requirements

I am using MacOS and I use brew for managing my dependencies, so I assume you will too, if not please install it by going to its official website and following the instructions.

Is not mandatory but for the ones interested, I am using the Alacritty terminal, so if you're interested you can download it using the following command in your terminal:

brew install --cask alacritty
Enter fullscreen mode Exit fullscreen mode

I think I will publish a post in future when I explain all my terminal configurations, but let's go back to our Neovim setup.

To install Neovim simply type this into your terminal:

brew install Neovim
Enter fullscreen mode Exit fullscreen mode

File structure

From now on we will see the Neovim config. You can find the full code in my dotfiles. Feel free to clone the repo and manipulate it as you want.

The config will be stored in ~/.config/nvim. In my case, I have a symlink to my dotfiles repo as you probably noticed if you checked the repo, it's not required.

If you don't have the folder created yet, you can do it running:

mkdir -p ~/.config/nvim
Enter fullscreen mode Exit fullscreen mode

and then go inside that directory:

cd ~/.config/nvim
Enter fullscreen mode Exit fullscreen mode

and create the main file for your config using lua as:

touch init.lua
Enter fullscreen mode Exit fullscreen mode

Apart from the main file, I am going to create two folders, one for the core config and the other for the plugins config; and a lazy.lua file to manage the lazy.nvim plugin manager config.

mkdir -p lua/charly3pins/core
Enter fullscreen mode Exit fullscreen mode
mkdir -p lua/charly3pins/plugins
Enter fullscreen mode Exit fullscreen mode
touch lua/charly3pins/lazy.lua
Enter fullscreen mode Exit fullscreen mode

Replace charly3pins with your username.

Core options

For the core options, I have 3 files with different configs in each and 1 that bundles all 3. First of all, move to the core directory.

cd lua/charly3pins/core
Enter fullscreen mode Exit fullscreen mode

Then create the 4 files as follows:

touch autocommands.lua
Enter fullscreen mode Exit fullscreen mode
touch init.lua
Enter fullscreen mode Exit fullscreen mode
touch keymaps.lua
Enter fullscreen mode Exit fullscreen mode
touch options.lua
Enter fullscreen mode Exit fullscreen mode

In the autocommands I have the following code:

-- Highlight when yanking (copying) text
--  Try it with `yap` in normal mode
--  See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", {
    desc = "Highlight when yanking (copying) text",
    group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }),
    callback = function()
        vim.highlight.on_yank()
    end,
})
Enter fullscreen mode Exit fullscreen mode

That is used when yanking text to highlight what I yank.

The keymaps is where I define all my shortcuts. I use the space as the leader as the trigger and the config of the different plugins:

vim.g.mapleader = " "

local keymap = vim.keymap

-- use jk to exit insert mode
keymap.set("i", "jk", "<ESC>", { desc = "Exit insert mode with jk" })

-- clear search highlights
keymap.set("n", "<leader>nh", ":nohl<CR>", { desc = "Clear search highlights" })

-- delete single character without copying into register
-- keymap.set("n", "x", '"_x')

-- increment/decrement numbers
keymap.set("n", "<leader>+", "<C-a>", { desc = "Increment number" }) -- increment
keymap.set("n", "<leader>-", "<C-x>", { desc = "Decrement number" }) -- decrement

-- window management
keymap.set("n", "<leader>sv", "<C-w>v", { desc = "Split window vertically" }) -- split window vertically
keymap.set("n", "<leader>sh", "<C-w>s", { desc = "Split window horizontally" }) -- split window horizontally
keymap.set("n", "<leader>se", "<C-w>=", { desc = "Make splits equal size" }) -- make split windows equal width & height
keymap.set("n", "<leader>sq", "<cmd>close<CR>", { desc = "Close current split" }) -- close current split window

keymap.set("n", "<leader>to", "<cmd>tabnew<CR>", { desc = "Open new tab" }) -- open new tab
keymap.set("n", "<leader>tq", "<cmd>tabclose<CR>", { desc = "Close current tab" }) -- close current tab
keymap.set("n", "<leader>tn", "<cmd>tabn<CR>", { desc = "Go to next tab" }) --  go to next tab
keymap.set("n", "<leader>tp", "<cmd>tabp<CR>", { desc = "Go to previous tab" }) --  go to previous tab
keymap.set("n", "<leader>tf", "<cmd>tabnew %<CR>", { desc = "Open current buffer in new tab" }) --  move current buffer to new tab

-- Disable arrow keys in normal mode
vim.keymap.set("n", "<left>", '<cmd>echo "Use h to move!!"<CR>')
vim.keymap.set("n", "<right>", '<cmd>echo "Use l to move!!"<CR>')
vim.keymap.set("n", "<up>", '<cmd>echo "Use k to move!!"<CR>')
vim.keymap.set("n", "<down>", '<cmd>echo "Use j to move!!"<CR>')
Enter fullscreen mode Exit fullscreen mode

In the options are the vim options for the basic editor functionalities:

vim.cmd("let g:netrw_liststyle = 3")

local opt = vim.opt

-- line numbers
opt.relativenumber = true
opt.number = true

-- tabs & indentation
opt.tabstop = 2 -- 2 spaces for tabs
opt.shiftwidth = 2 -- 2 spaces for indent width
opt.expandtab = true -- expand tab to spaces
opt.autoindent = true -- copy indent from current line when starting new one

-- line wrapping
opt.wrap = false -- disable line wrapping

-- search settings
opt.ignorecase = true -- ignore case when searching
opt.smartcase = true -- if you include mixed case in your search, assumes you want case-sensitive

-- cursor line
opt.cursorline = true -- highlight the current cursor line

-- appearance

-- turn on termguicolors for nightfly colorscheme to work
-- (have to use iterm2 or any other true color terminal)
opt.termguicolors = true
opt.background = "dark" -- colorschemes that can be light or dark will be made dark
opt.signcolumn = "yes" -- show sign column so that text doesn't shift

-- backspace
opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line or insert mode start position

-- clipboard
opt.clipboard:append("unnamedplus") -- use system clipboard as default register

-- split windows
opt.splitright = true -- split vertical window to the right
opt.splitbelow = true -- split horizontal window to the bottom
Enter fullscreen mode Exit fullscreen mode

Last the init file is where I bundle all of them as lua will execute the init first for each directory, so the content is simply this:

require("charly3pins.core.options")
require("charly3pins.core.keymaps")
require("charly3pins.core.autocommands")
Enter fullscreen mode Exit fullscreen mode

Lazy config

As I said, I use lazy.nvim as the plugin manager for Neovim so the next step is to go up one directory and edit our lazy.lua file to add the following:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({ { import = "charly3pins.plugins" }, { import = "charly3pins.plugins.lsp" } }, {
    change_detection = {
        notify = false,
    }
})
Enter fullscreen mode Exit fullscreen mode

For more details, you can find the documentation in the GitHub page.

Wrap the initial config

Once you have the core configuration files in place and the lazy.nvim config there is one step more you need to do before you can start playing around with the plugins.

Go to the root folder:

cd ~/.config/nvim
Enter fullscreen mode Exit fullscreen mode

and edit your init.lua file and add the following:

require("charly3pins.core")
require("charly3pins.lazy")
Enter fullscreen mode Exit fullscreen mode

Now you just need to restart the terminal, and if you open again your Neovim, you will be able to type :Lazy and see the plugin working.

Your folder structure should look like this:

  lua
    charly3pins
      core
    │ │  autocommands.lua
    │ │  init.lua
    │ │  keymaps.lua
    │ └  options.lua
      plugins
    └  lazy.lua
   init.lua
Enter fullscreen mode Exit fullscreen mode

My plugins

Here I will share the list of all the plugins that I use and their configuration. For more details please refer to each documentation or ask me a question below.

Each plugin needs to have a file with its name (the title in each section) .lua, like alpha.lua.

alpha

A lua powered greeter.

return {
  "goolord/alpha-nvim",
  event = "VimEnter",
  config = function()
    local alpha = require("alpha")
    local dashboard = require("alpha.themes.dashboard")

    -- Set header
    dashboard.section.header.val = {
      "                                                     ",
      "  ███╗   ██╗███████╗ ██████╗ ██╗   ██╗██╗███╗   ███╗ ",
      "  ████╗  ██║██╔════╝██╔═══██╗██║   ██║██║████╗ ████║ ",
      "  ██╔██╗ ██║█████╗  ██║   ██║██║   ██║██║██╔████╔██║ ",
      "  ██║╚██╗██║██╔══╝  ██║   ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
      "  ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
      "  ╚═╝  ╚═══╝╚══════╝ ╚═════╝   ╚═══╝  ╚═╝╚═╝     ╚═╝ ",
      "                                                     ",
    }

    -- Set menu
    dashboard.section.buttons.val = {
      dashboard.button("e", "  > New File", "<cmd>ene<CR>"),
      dashboard.button("SPC ee", "  > Toggle file explorer", "<cmd>NvimTreeToggle<CR>"),
      dashboard.button("SPC ff", "󰱼 > Find File", "<cmd>Telescope find_files<CR>"),
      dashboard.button("SPC fs", "  > Find Word", "<cmd>Telescope live_grep<CR>"),
      dashboard.button("SPC wr", "󰁯  > Restore Session For Current Directory", "<cmd>SessionRestore<CR>"),
      dashboard.button("q", " > Quit NVIM", "<cmd>qa<CR>"),
    }

    -- Send config to alpha
    alpha.setup(dashboard.opts)

    -- Disable folding on alpha buffer
    vim.cmd([[autocmd FileType alpha setlocal nofoldenable]])
  end,
}
Enter fullscreen mode Exit fullscreen mode

auto-session

A small automated session manager for Neovim.

return {
  "rmagatti/auto-session",
  config = function()
    local auto_session = require("auto-session")

    auto_session.setup({
      auto_restore_enabled = false,
      auto_session_suppress_dirs = { "~/", "~/Dev/", "~/Downloads", "~/Documents", "~/Desktop/" },
    })

    local keymap = vim.keymap

    keymap.set("n", "<leader>wr", "<cmd>SessionRestore<CR>", { desc = "Restore session for cwd" }) -- restore last workspace session for current directory
    keymap.set("n", "<leader>ws", "<cmd>SessionSave<CR>", { desc = "Save session for auto session root dir" }) -- save workspace session for current working directory
  end,
}
Enter fullscreen mode Exit fullscreen mode

bufferline

A snazzy bufferline for Neovim.

return {
  "akinsho/bufferline.nvim",
  dependencies = { "nvim-tree/nvim-web-devicons" },
  version = "*",
  opts = {
    options = {
      mode = "tabs",
      separator_style = "slant",
    },
  },
}
Enter fullscreen mode Exit fullscreen mode

colorscheme

Scheme of colors for Neovim.
I've been using the gruvbox for so long but I discovered a few weeks ago the craftzdog`s one and I am still using it, so I will share these 2 plus the tokyonight built by the one and only folke.

nvim
-- return {
-- "ellisonleao/gruvbox.nvim",
-- priority = 1000, -- make sure to load this before all the other start plugins
-- config = function()
-- vim.cmd("colorscheme gruvbox")
-- end,
-- }
-- return {
-- "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")
-- end,
-- }
return {
"craftzdog/solarized-osaka.nvim",
lazy = false,
priority = 1000,
opts = {},
config = function()
vim.cmd("colorscheme solarized-osaka")
end,
}

comment

Comment plugin for Neovim.

`nvim
return {
"numToStr/Comment.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"JoosepAlviste/nvim-ts-context-commentstring",
},
config = function()
-- import comment plugin safely
local comment = require("Comment")

local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim")

-- enable comment
comment.setup({
  -- for commenting tsx, jsx, svelte, html files
  pre_hook = ts_context_commentstring.create_pre_hook(),
})
Enter fullscreen mode Exit fullscreen mode

end,
}
`

dressing

Neovim plugin to improve the default vim.ui interfaces.

nvim
return {
"stevearc/dressing.nvim",
event = "VeryLazy",
}

formatting

Lightweight yet powerful formatter plugin for Neovim.

Here I have the configuration for my most used programming languages like go, python and web development. Also for the config files like json and yaml and my writing in markdown.

`nvim
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")

    conform.setup({
        formatters_by_ft = {
            css = { "prettier" },
            html = { "prettier" },
            json = { "prettier" },
            yaml = { "prettier" },
            markdown = { "prettier" },
            lua = { "stylua" },
            python = { "isort", "black" },
            go = { "goimports", "gofmt" },
        },
        format_on_save = {
            lsp_fallback = true,
            async = false,
            timeout_ms = 1000,
        },
    })

    vim.keymap.set({ "n", "v" }, "<leader>cp", function()
        conform.format({
            lsp_fallback = true,
            async = false,
            timeout_ms = 1000,
        })
    end, { desc = "Format file or range (in visual mode)" })
end,
Enter fullscreen mode Exit fullscreen mode

}
`

gitsigns

Git integration for buffers.

`nvim
return {
"lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = {
on_attach = function(bufnr)
local gs = package.loaded.gitsigns

  local function map(mode, l, r, desc)
    vim.keymap.set(mode, l, r, { buffer = bufnr, desc = desc })
  end

  -- Navigation
  map("n", "]h", gs.next_hunk, "Next Hunk")
  map("n", "[h", gs.prev_hunk, "Prev Hunk")

  -- Actions
  map("n", "<leader>hs", gs.stage_hunk, "Stage hunk")
  map("n", "<leader>hr", gs.reset_hunk, "Reset hunk")
  map("v", "<leader>hs", function()
    gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
  end, "Stage hunk")
  map("v", "<leader>hr", function()
    gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
  end, "Reset hunk")

  map("n", "<leader>hS", gs.stage_buffer, "Stage buffer")
  map("n", "<leader>hR", gs.reset_buffer, "Reset buffer")

  map("n", "<leader>hu", gs.undo_stage_hunk, "Undo stage hunk")

  map("n", "<leader>hp", gs.preview_hunk, "Preview hunk")

  map("n", "<leader>hb", function()
    gs.blame_line({ full = true })
  end, "Blame line")
  map("n", "<leader>hB", gs.toggle_current_line_blame, "Toggle line blame")

  map("n", "<leader>hd", gs.diffthis, "Diff this")
  map("n", "<leader>hD", function()
    gs.diffthis("~")
  end, "Diff this ~")

  -- Text object
  map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "Gitsigns select hunk")
end,
Enter fullscreen mode Exit fullscreen mode

},
}
`

indent-blankline

Indent guides for Neovim.

nvim
return {
"lukas-reineke/indent-blankline.nvim",
event = { "BufReadPre", "BufNewFile" },
main = "ibl",
opts = {
-- indent = { char = "┊" },
indent = {
char = "│",
tab_char = "│",
},
}
}

init.lua

As with other directories, this is not a plugin it's just the entry file that lua looks for in each directory.

nvim
return {
"nvim-lua/plenary.nvim", -- lua functions that many plugins use
"christoomey/vim-tmux-navigator", -- tmux & split window navigation
}

lazygit

Plugin for calling lazygit from within Neovim.

To make sure this works, install it using brew first:

sh
brew install jesseduffield/lazygit/lazygit

nvim
return {
"kdheepak/lazygit.nvim",
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
-- setting the keybinding for LazyGit with 'keys' is recommended in
-- order to load the plugin when the command is run for the first time
keys = {
{ "<leader>lg", "<cmd>LazyGit<cr>", desc = "Open lazy git" },
},
}

linting

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.

`nvim
return {
"mfussenegger/nvim-lint",
event = { "BufReadPre", "BufNewFile" },
config = function()
local lint = require("lint")

lint.linters_by_ft = {
  go = { "golangcilint" },
  python = { "pylint" },
}

local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })

vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
  group = lint_augroup,
  callback = function()
    lint.try_lint()
  end,
})

vim.keymap.set("n", "<leader>l", function()
  lint.try_lint()
end, { desc = "Trigger linting for current file" })
Enter fullscreen mode Exit fullscreen mode

end,
}
`

lualine

A blazing fast and easy to configure Neovim statusline plugin written in pure lua.

`nvim
return {
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
local lualine = require("lualine")

local colors = {
  blue = "#65D1FF",
  green = "#3EFFDC",
  violet = "#FF61EF",
  yellow = "#FFDA7B",
  red = "#FF4A4A",
  fg = "#c3ccdc",
  bg = "#112638",
  inactive_bg = "#2c3043",
}

local my_lualine_theme = {
  normal = {
    a = { bg = colors.blue, fg = colors.bg, gui = "bold" },
    b = { bg = colors.bg, fg = colors.fg },
    c = { bg = colors.bg, fg = colors.fg },
  },
  insert = {
    a = { bg = colors.green, fg = colors.bg, gui = "bold" },
    b = { bg = colors.bg, fg = colors.fg },
    c = { bg = colors.bg, fg = colors.fg },
  },
  visual = {
    a = { bg = colors.violet, fg = colors.bg, gui = "bold" },
    b = { bg = colors.bg, fg = colors.fg },
    c = { bg = colors.bg, fg = colors.fg },
  },
  command = {
    a = { bg = colors.yellow, fg = colors.bg, gui = "bold" },
    b = { bg = colors.bg, fg = colors.fg },
    c = { bg = colors.bg, fg = colors.fg },
  },
  replace = {
    a = { bg = colors.red, fg = colors.bg, gui = "bold" },
    b = { bg = colors.bg, fg = colors.fg },
    c = { bg = colors.bg, fg = colors.fg },
  },
  inactive = {
    a = { bg = colors.inactive_bg, fg = colors.semilightgray, gui = "bold" },
    b = { bg = colors.inactive_bg, fg = colors.semilightgray },
    c = { bg = colors.inactive_bg, fg = colors.semilightgray },
  },
}

-- configure lualine with modified theme
lualine.setup({
  options = {
    theme = my_lualine_theme,
  },
})
Enter fullscreen mode Exit fullscreen mode

end,
}
`

markdown-preview

Markdown preview plugin for Neovim.

`nvim
return {
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
ft = { "markdown" },
build = function()
vim.fn"mkdp#util#install"
end,
config = function()
local keymap = vim.keymap

    keymap.set("n", "<leader>mp", "<cmd>MarkdownPreview<cr>", { desc = "Markdown Preview" })
    keymap.set("n", "<leader>ms", "<cmd>MarkdownPreviewStop<cr>", { desc = "Markdown Preview Stop" })
    keymap.set("n", "<leader>mt", "<cmd>MarkdownPreviewToggle<cr>", { desc = "Markdown Preview Toggle" })
end,
Enter fullscreen mode Exit fullscreen mode

}
`

mini

Neovim Lua plugin to visualize and operate on indent scope. Part of 'mini.nvim' library.

nvim
return {
"echasnovski/mini.indentscope",
version = false,
opts = {
symbol = "│",
},
}

nvim-cmp

A completion plugin for Neovim coded in Lua.

`nvim
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-buffer", -- source for text in buffer
"hrsh7th/cmp-path", -- source for file system paths
{
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "v2.*", -- Replace by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp",
},
"saadparwaiz1/cmp_luasnip", -- for autocompletion
"rafamadriz/friendly-snippets", -- useful snippets
"onsails/lspkind.nvim", -- vs-code like pictograms
},
config = function()
local cmp = require("cmp")

local luasnip = require("luasnip")

local lspkind = require("lspkind")

-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
require("luasnip.loaders.from_vscode").lazy_load()

cmp.setup({
  completion = {
    completeopt = "menu,menuone,preview,noselect",
  },
  snippet = { -- configure how nvim-cmp interacts with snippet engine
    expand = function(args)
      luasnip.lsp_expand(args.body)
    end,
  },
  mapping = cmp.mapping.preset.insert({
    ["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
    ["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
    ["<C-b>"] = cmp.mapping.scroll_docs(-4),
    ["<C-f>"] = cmp.mapping.scroll_docs(4),
    ["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
    ["<C-e>"] = cmp.mapping.abort(), -- close completion window
    ["<CR>"] = cmp.mapping.confirm({ select = false }),
  }),
  -- sources for autocompletion
  sources = cmp.config.sources({
            { name = "nvim_lsp" }, -- lsp
    { name = "luasnip" }, -- snippets
    { name = "buffer" }, -- text within current buffer
    { name = "path" }, -- file system paths
  }),

  -- configure lspkind for vs-code like pictograms in completion menu
  formatting = {
    format = lspkind.cmp_format({
      maxwidth = 50,
      ellipsis_char = "...",
    }),
  },
})
Enter fullscreen mode Exit fullscreen mode

end,
}
`

nvim-tree

A file explorer tree for Neovim written in lua.

`nvim
return {
"nvim-tree/nvim-tree.lua",
dependencies = "nvim-tree/nvim-web-devicons",
config = function()
local nvimtree = require("nvim-tree")

-- recommended settings from nvim-tree documentation
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

nvimtree.setup({
  view = {
    width = 35,
    relativenumber = true,
  },
  -- change folder arrow icons
  renderer = {
    indent_markers = {
      enable = true,
    },
    icons = {
      glyphs = {
        folder = {
          arrow_closed = "", -- arrow when folder is closed
          arrow_open = "", -- arrow when folder is open
        },
      },
    },
  },
  -- disable window_picker for
  -- explorer to work well with
  -- window splits
  actions = {
    open_file = {
      window_picker = {
        enable = false,
      },
    },
  },
  filters = {
    custom = { ".DS_Store" },
  },
  git = {
    ignore = false,
  },
})

-- set keymaps
local keymap = vim.keymap

keymap.set("n", "<leader>ee", "<cmd>NvimTreeToggle<CR>", { desc = "Toggle file explorer" }) -- toggle file explorer
keymap.set("n", "<leader>ef", "<cmd>NvimTreeFindFileToggle<CR>", { desc = "Toggle file explorer on current file" }) -- toggle file explorer on current file
keymap.set("n", "<leader>ec", "<cmd>NvimTreeCollapse<CR>", { desc = "Collapse file explorer" }) -- collapse file explorer
keymap.set("n", "<leader>er", "<cmd>NvimTreeRefresh<CR>", { desc = "Refresh file explorer" }) -- refresh file explorer
Enter fullscreen mode Exit fullscreen mode

end
}
`

surround

Add/change/delete surrounding delimiter pairs with ease.

nvim
return {
"kylechui/nvim-surround",
event = { "BufReadPre", "BufNewFile" },
version = "*", -- Use for stability; omit to use
mainbranch for the latest features
config = true,
}

telescope

A fuzzy finder over lists offering the following options: Find, Filter, Preview, Pick.

`nvim
return {
"nvim-telescope/telescope.nvim",
branch = "0.1.x",
dependencies = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
"nvim-tree/nvim-web-devicons",
},
config = function()
local telescope = require("telescope")
local actions = require("telescope.actions")

telescope.setup({
  defaults = {
    path_display = { "smart" },
    mappings = {
      i = {
        ["<C-k>"] = actions.move_selection_previous, -- move to prev result
        ["<C-j>"] = actions.move_selection_next, -- move to next result
        ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist, -- send selected items to quickfix list
      },
    },
  },
})

telescope.load_extension("fzf")

-- set keymaps
local keymap = vim.keymap

keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Fuzzy find files in cwd" })
keymap.set("n", "<leader>fr", "<cmd>Telescope oldfiles<cr>", { desc = "Fuzzy find recent files" })
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>", { desc = "Find string in cwd" })
keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>", { desc = "Find string under cursor in cwd" })
Enter fullscreen mode Exit fullscreen mode

end,
}
`

todo-comments

Highlight, list and search todo comments in your projects.

`nvim
return {
"folke/todo-comments.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local todo_comments = require("todo-comments")

-- set keymaps
local keymap = vim.keymap -- for conciseness

keymap.set("n", "]t", function()
  todo_comments.jump_next()
end, { desc = "Next todo comment" })

keymap.set("n", "[t", function()
  todo_comments.jump_prev()
end, { desc = "Previous todo comment" })

todo_comments.setup()
Enter fullscreen mode Exit fullscreen mode

end,
}
`

treesitter

Highlighting plugin.

Here are my most used languages as before with an extra config for using with templ.

`nvim
return {
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPre", "BufNewFile" },
build = ":TSUpdate",
dependencies = {
"windwp/nvim-ts-autotag",
"vrischmann/tree-sitter-templ",
},
config = function()
vim.treesitter.language.register("templ", "templ")

    local treesitter = require("nvim-treesitter.configs")

    -- configure treesitter
    treesitter.setup({
        highlight = {
            enable = true,
        },
        indent = { enable = true },
        autotag = {
            enable = true,
        },
        ensure_installed = {
            "json",
            "yaml",
            "html",
            "css",
            "go",
            "templ",
            "markdown",
            "markdown_inline",
            "bash",
            "lua",
            "vim",
            "dockerfile",
            "gitignore",
            "query",
            "vimdoc",
            "dart",
            "python",
        },
        incremental_selection = {
            enable = true,
            keymaps = {
                init_selection = "<C-space>",
                node_incremental = "<C-space>",
                scope_incremental = false,
                node_decremental = "<bs>",
            },
        },
    })
end,
Enter fullscreen mode Exit fullscreen mode

}
`

trouble

A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.

nvim
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons", "folke/todo-comments.nvim" },
keys = {
{ "<leader>xx", "<cmd>TroubleToggle<CR>", desc = "Open/close trouble list" },
{ "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<CR>", desc = "Open trouble workspace diagnostics" },
{ "<leader>xd", "<cmd>TroubleToggle document_diagnostics<CR>", desc = "Open trouble document diagnostics" },
{ "<leader>xq", "<cmd>TroubleToggle quickfix<CR>", desc = "Open trouble quickfix list" },
{ "<leader>xl", "<cmd>TroubleToggle loclist<CR>", desc = "Open trouble location list" },
{ "<leader>xt", "<cmd>TodoTrouble<CR>", desc = "Open todos in trouble" },
},
}

vim-maximizer

Maximizes and restores the current window in Vim.

nvim
return {
"szw/vim-maximizer",
keys = {
{ "<leader>sm", "<cmd>MaximizerToggle<CR>", desc = "Maximize/minimize a split" },
},
}

which-key

Helps you remember your Neovim keymaps, by showing available keybindings in a popup as you type.

nvim
return {
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 500
end,
opts = {},
}

Conclusion

If you got here, congratulations because the list, as you can see, is quite extensive.

As you probably know, the list of plugins for Neovim is tremendously huge and sometimes it can make us anxious and generate doubts about how we can start and which plugins can help us.

I hope that with this list of mine and the ready-to-use configuration that I have left you, you can have a starting point and start creating your own editor to your liking little by little until you reach the perfect configuration for you.

If you have plugins that you have not seen on my list that you think are interesting for me to try, please share them with me since I always like to discover and try new things, I would really appreciate it.

I hope everything that I have tried to explain in this post has been clear, and please if there is any part that has not been completely clear or there are parts that I have not covered that you would like me to do, leave me a comment right here or through my social networks that you have on my profile and I will be happy to respond.

Happy coding!

{C3P}

Top comments (0)