Skip to content

Instantly share code, notes, and snippets.

@DanielFGray
Last active June 28, 2025 17:02
Show Gist options
  • Save DanielFGray/4615af89345e540942e0975c7203beeb to your computer and use it in GitHub Desktop.
Save DanielFGray/4615af89345e540942e0975c7203beeb to your computer and use it in GitHub Desktop.
current init.lua
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.g.loaded_netrwPlugin = 1
vim.opt.autoread = true
vim.opt.backspace = "indent,eol,start" -- backspace over everything
vim.opt.colorcolumn = { 80 } -- highlight 80th column
vim.opt.confirm = true -- y/n save prompt on quit
vim.opt.equalalways = true
vim.opt.foldexpr = "nvim_treesitter#foldexpr()" -- fold by expressions
vim.opt.foldlevelstart = 999 -- open all folds by default
vim.opt.foldmethod = "expr"
vim.opt.hidden = true -- switch buffers without saving
vim.opt.hlsearch = true
vim.opt.incsearch = true -- visual searching
vim.opt.linebreak = true -- break at word boundaries when wrap enabled
vim.opt.list = true
vim.opt.listchars = { tab = " ", trail = "★" } -- visible tab chars and trailing spaces
vim.opt.listchars:append({ extends = "»", precedes = "«" }) -- custom line wrap chars
-- vim.opt.listchars:append({ eol = '¬', space = '🞄' }) -- visible space and eol chars (very noisy)
vim.opt.modeline = true
vim.opt.mouse = "nv" -- mouse on for normal,visual mode (but not insert while typing)
vim.opt.number = true -- toggle with yon -- show current line number (0 with rnu)
vim.opt.relativenumber = true -- toggle with yor -- line numbers relative to current position
vim.opt.showcmd = true -- visual operator pending
vim.opt.showmode = false -- hide mode indicator from command (already shown in statusline)
vim.opt.showtabline = 2 -- always show tabline
vim.opt.laststatus = 3 -- always show statusline
vim.opt.signcolumn = "yes" -- always keep the sign column open
vim.opt.smarttab = true
vim.opt.splitright = false -- split defaults
vim.opt.timeoutlen = 200 -- see help
vim.opt.ttimeoutlen = 50 -- see help
vim.opt.backupdir = vim.fn.stdpath("config") .. "/backups//" -- vim backups in vim dir
vim.opt.undodir = vim.fn.stdpath("config") .. "/undo//" -- undofiles in vim dir
vim.opt.directory = vim.fn.stdpath("config") .. "/swaps//" -- swap files in vim dir
vim.opt.undofile = true -- enable persistent undo files
vim.opt.updatetime = 100 -- cursorhold time and writing swap file debounce time in ms,
vim.opt.wrap = false -- toggle with yow -- disable linewrap
-- vim.opt.termguicolors = true
-- ╒══ Disable hlsearch while loading viminfo
-- │ ╒══ Remember marks for last 500 files
-- │ │ ╒══ Remember last 1000 commands
-- │ │ │ ╒══ Remember last 1000 search patterns
-- │ │ │ │ ╒══ Remember up to 1MB in each register
-- │ │ │ │ │ ╒═══ Remember up to 10000 lines in each register
-- │ │ │ │ │ │
-- │ │ │ │ │ │
vim.cmd([[set viminfo=h,'500,:1000,/1000,s1000,<10000]])
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
-- is not what someone will guess without a bit more experience.
--
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
-- or just use <C-\><C-n> to exit terminal mode
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
vim.diagnostic.config({
signs = {
text = {
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "",
[vim.diagnostic.severity.ERROR] = "",
},
},
})
-- make Y behave like C and D
vim.keymap.set("", "Y", "y$")
-- swap ' and `
vim.keymap.set("", "'", "`")
vim.keymap.set("", "`", "'")
-- an attempt at exclusive folds
vim.keymap.set("n", "zj", "zjzMzvzz", { desc = "Jump to the fold below", silent = true })
vim.keymap.set("n", "zk", "zkzMzvzz", { desc = "Jump to the fold above", silent = true })
vim.keymap.set("n", "za", "zazMzvzz", { desc = "Toggle fold under cursor", silent = true })
-- unimpaired-like expandtab toggle
vim.keymap.set("n", "yoe", "<Cmd>set expandtab!<CR>", { desc = "Toggle expandtab", silent = true })
vim.keymap.set(
"n",
"<Leader>ec",
':e <C-r>=stdpath("config")<CR>/init.lua<CR>',
{ desc = "edit config file", silent = true }
)
-- quicker :s mappings
-- see also :h c_CTRL-R_CTRL-W
vim.keymap.set(
"n",
"<Leader>ss",
"<esc>:s///gc<left><left><left><left>",
{ desc = ":subsitute on current line", silent = true }
)
vim.keymap.set(
"n",
"<Leader>sS",
"<esc>:%s///gc<left><left><left><left>",
{ desc = ":subsitute on all lines", silent = true }
)
vim.keymap.set("x", "<Leader>s", ":s///gc<left><left>", { desc = ":subsitute on selection", silent = true })
-- insert timestamp with ctrl-t
vim.keymap.set(
{ "c", "i" },
"<C-t>",
'<C-r>=strftime("%FT%TZ")<Left><Left>',
{ desc = "insert timestamp", silent = true }
)
vim.keymap.set(
"n",
"<Leader>cl",
"execute 'norm! yiwoconsole.log({})' | norm! hhp",
{ desc = "console.log current word", silent = true }
)
-- vim.api.nvim_create_autocmd("ColorScheme", {
-- pattern = "*",
-- callback = function()
-- vim.api.nvim_set_hl(0, "LspReferenceText", { ctermbg = "black" })
-- vim.api.nvim_set_hl(0, "Whitespace", { ctermfg = 0 })
-- vim.api.nvim_set_hl(0, "NonText", { ctermfg = 0 })
-- vim.api.nvim_set_hl(0, "SpecialKey", { ctermfg = 0 })
-- vim.api.nvim_set_hl(0, "WinSeparator", { ctermbg = "none", ctermfg = "black" })
-- vim.api.nvim_set_hl(0, "DiffChange", { ctermbg = "none", ctermfg = "yellow" })
-- vim.api.nvim_set_hl(0, "DiffAdd", { ctermbg = "none", ctermfg = "green" })
-- vim.api.nvim_set_hl(0, "DiffDelete", { ctermbg = "none", ctermfg = "red" })
-- vim.api.nvim_set_hl(0, "Sneak", { ctermfg = "black", ctermbg = "white" })
-- vim.api.nvim_set_hl(0, "WinBar", { ctermbg = "black" })
-- end,
-- group = vim.api.nvim_create_augroup("colorscheme", { clear = true }),
-- })
vim.cmd([[
" expand %% in the command prompt to the current dir
cabbrev %% <C-r>=fnameescape(expand('%:h'))<CR>
" common typing mistakes
iabbrev functino function
iabbrev seperate separate
iabbrev actino action
iabbrev improt import
iabbrev frmo from
iabbrev teh the
" common command typos
command! -bang W w<bang>
command! -bang Q q<bang>
command! -bang Qa qa<bang>
command! -bang QA qa<bang>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Wqa wqa<bang>
command! -bang WQa wqa<bang>
command! -bang WQA wqa<bang>
" autocmds
augroup Vim
" always wrap autocmds in an augroup
" reset the augroup so autocmds don't stack on reload
autocmd!
" reload init.lua on save
autocmd BufWritePost $MYVIMRC
\ execute 'luafile %'
" restore last known position in file
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line('$') |
\ execute 'normal! g`"zvzz' |
\ endif
" start git commits in insert mode with spelling and textwidth
autocmd FileType gitcommit
\ setlocal spell textwidth=72 |
\ startinsert
" use q to close non-files (help, quickfix, etc)
autocmd BufEnter *
\ if &buftype != '' |
\ nnoremap <silent><buffer> q :<C-u>bw<CR> |
\ endif
" open :help to the right at 80 columns
autocmd FileType help
\ wincmd L |
\ vert resize 81
" expand help when focused
autocmd BufEnter *
\ if &filetype ==? 'help' |
\ execute 'normal 0' |
\ vert resize 81 |
\ endif
" make help small when unfocus
autocmd BufLeave *
\ if &filetype ==? 'help' |
\ vert resize 10 |
\ endif
" make help small when vim resized
autocmd VimResized help
\ vert resize 10
autocmd TermOpen *
\ setlocal nonu nornu signcolumn=no
augroup END
if exists('g:neovide') || exists('g:goneovim')
set guifont=FiraCode\ Nerd\ Font:h9
let g:neovide_floating_blur_amount_x = 2.0
let g:neovide_floating_blur_amount_y = 2.0
let g:neovide_cursor_animation_length = 0
set termguicolors
endif
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction " }}}
set foldtext=MyFoldText()
]])
-- 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,
})
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
error("Error cloning lazy.nvim:\n" .. out)
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
-- utils/commands/maps
{
"https://github.com/ibhagwan/fzf-lua",
cmd = "FzfLua",
keys = {
{ "<leader>b", "<Cmd>FzfLua buffers<CR>" },
{ "<leader>ff", "<Cmd>FzfLua files<CR>" },
{ "<leader>/", "<Cmd>FzfLua live_grep<CR>" },
{ "gra", "<Cmd>FzfLua lsp_code_actions<CR>" },
{ "gd", "<Cmd>FzfLua lsp_definitions<CR>" },
{ "<leader>fr", "<Cmd>FzfLua oldfiles<CR>" },
{ "<leader>tf", "<Cmd>FzfLua resume<CR>" },
},
opts = {
winopts = {
border = false,
},
fzf_opts = {
["--input-border"] = true,
["--list-border"] = true,
["--header-border"] = true,
["--info"] = "inline-right",
},
preview = {
winopts = {
border = false,
},
},
},
},
{
"https://github.com/jebaum/vim-tmuxify", -- tmux integration
init = function()
vim.g.tmuxify_map_prefix = "<Leader>x"
vim.g.tmuxify_custom_command = "tmux splitw -dv -p25"
vim.g.tmuxify_global_maps = 1
vim.g.tmuxify_run = {
lilypond = ' f="%"; lilypond "$f" && x-pdf "${f/%ly/pdf}"; unset f',
tex = ' f="%"; texi2pdf "$f" && x-pdf "${f/%tex/pdf}"; unset f',
ruby = " ruby %",
python = " python %",
typescript = " ts-node %",
javascript = " node %",
}
end,
},
"https://github.com/vim-utils/vim-husk", -- readline command maps
"https://github.com/tpope/vim-abolish", -- extended subsititions and replacements `:S :Ab`
"https://github.com/tpope/vim-eunuch", -- simple commands for common linux tasks
"https://github.com/tpope/vim-sleuth", -- better indent/buffer type detection
{
"https://github.com/tpope/vim-unimpaired", -- lots of keybinds `[e ]b yox`
keys = { "[", "]", "yo", "<", ">", "=" },
},
"https://github.com/tpope/vim-dotenv", -- make .env vars accessible
"https://github.com/tpope/vim-fugitive", -- git integration
"https://github.com/haya14busa/is.vim", -- better incsearch highlighting
"https://github.com/chrisbra/NrrwRgn", -- `:NR` edits selected regions in separate buffer
"https://github.com/zx2c4/password-store", -- disable viminfo etc for files in ~/.password-store
{ "https://github.com/stevearc/stickybuf.nvim", opts = {} },
{
"https://github.com/folke/trouble.nvim",
dependencies = "https://github.com/nvim-tree/nvim-web-devicons",
opts = {
use_diagnostic_signs = true,
},
cmd = { "Trouble" },
keys = {
{ "grr", "<cmd>Trouble lsp_references focus<cr>", desc = "Show References", mode = "n", silent = true },
{ "tT", "<cmd>Trouble diagnostics focus<cr>", desc = "Show References", mode = "n", silent = true },
},
},
{
"https://github.com/folke/todo-comments.nvim",
dependencies = { "https://github.com/nvim-lua/plenary.nvim" },
opts = {},
},
{
"https://github.com/nvim-treesitter/nvim-treesitter",
event = { "BufReadPre", "BufNewFile" },
lazy = true,
build = ":TSUpdate",
main = "nvim-treesitter.configs", -- Sets main module to use for opts
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = {
ensure_installed = {
"bash",
"c",
"clojure",
"cmake",
"cpp",
"css",
"diff",
"dockerfile",
"gitignore",
"graphql",
"haskell",
"html",
"javascript",
"json",
"json5",
"jsonc",
"lua",
"luadoc",
"make",
"markdown",
"markdown_inline",
"perl",
"python",
"query",
"regex",
"rust",
"sql",
"tsx",
"typescript",
"vim",
"vimdoc",
"yaml",
},
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
enable = true,
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { "ruby" },
},
indent = { enable = true, disable = { "ruby" } },
endwise = { enable = true },
matchup = { enable = true },
autotag = { enable = true },
textobjects = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gri",
node_incremental = "gri",
node_decremental = "grd",
scope_incremental = "grc", -- what even is this?
},
},
},
-- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you:
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
},
-- LSP
{
"https://github.com/folke/lazydev.nvim", -- LSP for nvim apis
ft = "lua",
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
{
"https://github.com/neovim/nvim-lspconfig",
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
-- Mason must be loaded before its dependents so we need to set it up here.
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
{ "https://github.com/williamboman/mason.nvim", opts = {} },
"https://github.com/williamboman/mason-lspconfig.nvim",
"https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim",
-- Useful status updates for LSP.
{ "https://github.com/j-hui/fidget.nvim", opts = {} },
-- Allows extra capabilities provided by nvim-cmp
"https://github.com/hrsh7th/cmp-nvim-lsp",
},
config = function()
-- Brief aside: **What is LSP?**
--
-- LSP is an initialism you've probably heard, but might not understand what it is.
--
-- LSP stands for Language Server Protocol. It's a protocol that helps editors
-- and language tooling communicate in a standardized fashion.
--
-- In general, you have a "server" which is some tool built to understand a particular
-- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
-- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
-- processes that communicate with some "client" - in this case, Neovim!
--
-- LSP provides Neovim with features like:
-- - Go to definition
-- - Find references
-- - Autocompletion
-- - Symbol Search
-- - and more!
--
-- Thus, Language Servers are external tools that must be installed separately from
-- Neovim. This is where `mason` and related plugins come into play.
--
-- If you're wondering about lsp vs treesitter, you can check out the wonderfully
-- and elegantly composed help section, `:help lsp-vs-treesitter`
-- This function gets run when an LSP attaches to a particular buffer.
-- That is to say, every time a new file is opened that is associated with
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
-- function will be executed to configure the current buffer
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
callback = function(event)
vim.keymap.set(
"n",
"gl",
vim.diagnostic.open_float,
{ buffer = event.buf, desc = "Show Diagnostics", silent = true }
)
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
local highlight_augroup =
vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd("LspDetach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
end,
})
end
-- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
vim.keymap.set("n", "<leader>th", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
end, { desc = "Toggle Inlay Hints" })
end
end,
})
-- Change diagnostic symbols in the sign column (gutter)
-- if vim.g.have_nerd_font then
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
-- local diagnostic_signs = {}
-- for type, icon in pairs(signs) do
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
-- end
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
-- end
-- LSP servers and clients are able to communicate to each other what features they support.
-- By default, Neovim doesn't support everything that is in the LSP specification.
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
-- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
-- Add any additional override configuration in the following tables. Available keys are:
-- - cmd (table): Override the default command used to start the server
-- - filetypes (table): Override the default list of associated filetypes for the server
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
--
lua_ls = {
-- cmd = { ... },
-- filetypes = { ... },
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
},
}
-- Ensure the servers and tools above are installed
--
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
-- :Mason
--
-- You can press `g?` for help in this menu.
--
-- `mason` had to be setup earlier: to configure its options see the
-- `dependencies` table for `nvim-lspconfig` above.
--
-- You can add other tools here that you want Mason to install
-- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
"stylua", -- Used to format Lua code
})
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
require("mason-lspconfig").setup({
handlers = {
function(server_name)
local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for ts_ls)
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
require("lspconfig")[server_name].setup(server)
end,
},
})
end,
},
{
"https://github.com/stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
"<leader>cf",
function()
require("conform").format({ async = true, lsp_format = "fallback" })
end,
mode = "",
desc = "Format buffer",
},
},
opts = {
notify_on_error = false,
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
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true }
local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = "never"
else
lsp_format_opt = "fallback"
end
return {
timeout_ms = 500,
lsp_format = lsp_format_opt,
}
end,
formatters_by_ft = {
lua = { "stylua" },
-- Conform can also run multiple formatters sequentially
-- 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 },
},
},
},
{
"https://github.com/hrsh7th/nvim-cmp", -- Autocompletion
event = "InsertEnter",
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
{
"https://github.com/L3MON4D3/LuaSnip",
build = (function()
-- Build Step is needed for regex support in snippets.
-- This step is not supported in many windows environments.
-- Remove the below condition to re-enable on windows.
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
return
end
return "make install_jsregexp"
end)(),
dependencies = {
-- `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,
-- },
},
},
"https://github.com/saadparwaiz1/cmp_luasnip",
-- Adds other completion capabilities.
-- nvim-cmp does not ship with all sources by default. They are split
-- into multiple repos for maintenance purposes.
"https://github.com/hrsh7th/cmp-nvim-lsp",
"https://github.com/hrsh7th/cmp-path",
{
"https://github.com/zbirenbaum/copilot-cmp",
config = function()
require("copilot_cmp").setup()
end,
},
},
config = function()
-- See `:help cmp`
local cmp = require("cmp")
local luasnip = require("luasnip")
luasnip.config.setup({})
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = { completeopt = "menu,menuone,noinsert" },
-- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert({
-- Select the [n]ext item
["<C-n>"] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
["<C-p>"] = cmp.mapping.select_prev_item(),
-- Scroll the documentation window [b]ack / [f]orward
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
["<CR>"] = cmp.mapping.confirm({ select = true }),
-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
["<C-Space>"] = cmp.mapping.complete({}),
-- Think of <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like:
-- function $name($args)
-- $body
-- end
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { "i", "s" }),
["<C-h>"] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { "i", "s" }),
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
}),
sources = {
{ name = "copilot", group_index = 2 },
{
name = "lazydev",
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
},
})
end,
},
{
"https://github.com/zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
opts = {
suggestion = { enabled = false },
panel = { enabled = false },
},
},
{
"https://github.com/yetone/avante.nvim",
event = "VeryLazy",
version = false, -- Never set this value to "*"! Never!
opts = {
provider = "copilot",
hints = { enabled = false },
suggestion = {
debounce = 600,
throttle = 600,
},
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
build = "make",
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
dependencies = {
"https://github.com/nvim-treesitter/nvim-treesitter",
"https://github.com/stevearc/dressing.nvim",
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/MunifTanjim/nui.nvim",
--- The below dependencies are optional,
"https://github.com/hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
"https://github.com/ibhagwan/fzf-lua", -- for file_selector provider fzf
"https://github.com/nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
"https://github.com/zbirenbaum/copilot.lua", -- for providers='copilot'
{
"https://github.com/HakonHarnes/img-clip.nvim", -- support for image pasting
event = "VeryLazy",
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
},
},
{
"https://github.com/MeanderingProgrammer/render-markdown.nvim", -- Make sure to set this up properly if you have lazy=true
opts = {
file_types = { "markdown", "Avante" },
},
ft = { "markdown", "Avante" },
},
},
},
-- operators
"https://github.com/tpope/vim-repeat", -- enables repeat `.` for plugins
"https://github.com/tpope/vim-commentary", -- toggle comments `gc<motion>`
"https://github.com/tpope/vim-surround", -- manage surrounding pairs `ds.. cs.. ys..`
"https://github.com/tommcdo/vim-exchange", -- swap selections `cx<motion>` in normal `X` in visual
"https://github.com/AndrewRadev/splitjoin.vim", -- smarter `gJ` joins and split with `gS`
"https://github.com/tpope/vim-speeddating", -- ctrl-x/a works on dates
"https://github.com/Konfekt/vim-CtrlXA", -- ctrl-x/a works on other stuff
"https://github.com/christoomey/vim-titlecase", -- Title Case mappings
{
"https://github.com/junegunn/vim-easy-align", -- automatic visual alignments
keys = {
{ "ga", "<Plug>(EasyAlign)", mode = { "n", "x" }, desc = "Align text", silent = true },
},
},
{
"https://github.com/dahu/Insertlessly", -- insert newline with enter
init = function()
vim.g.insertlessly_insert_newlines = 1
vim.g.insertlessly_open_newlines = 0
vim.g.insertlessly_backspace_past_bol = 1
vim.g.insertlessly_delete_at_eol_joins = 1
vim.g.insertlessly_insert_spaces = 0
vim.g.insertlessly_cleanup_trailing_ws = 0
vim.g.insertlessly_cleanup_all_ws = 0
vim.g.insertlessly_adjust_cursor = 1
end,
},
{
"https://github.com/aaronik/treewalker.nvim",
keys = {
{ "<leader>sk", "<cmd>Treewalker SwapUp<cr>", mode = { "x", "n" }, silent = true, desc = "swap up" },
{ "<leader>sj", "<cmd>Treewalker SwapDown<cr>", mode = { "x", "n" }, silent = true, desc = "swap down" },
{ "<leader>sh", "<cmd>Treewalker SwapLeft<cr>", mode = { "x", "n" }, silent = true, desc = "swap left" },
{ "<leader>sl", "<cmd>Treewalker SwapRight<cr>", mode = { "x", "n" }, silent = true, desc = "swap right" },
},
opts = {},
},
-- motions
{
"https://github.com/justinmk/vim-sneak", -- linewise `fFtT;,` and two char sneak `s.. S..`
keys = {
{ "s", "<Plug>Sneak_s", desc = "Sneak forwards" },
{ "S", "<Plug>Sneak_S", desc = "Sneak backwards" },
{ "f", "<Plug>Sneak_f", desc = "Move to next char" },
{ "F", "<Plug>Sneak_F", desc = "Move to previous char" },
{ "t", "<Plug>Sneak_t", desc = "Move before next char" },
{ "T", "<Plug>Sneak_T", desc = "Move before previous char" },
{ "z", "<Plug>Sneak_s", desc = "Sneak forwards", mode = "o" },
{ "Z", "<Plug>Sneak_S", desc = "Sneak backwards", mode = "o" },
{ ";", "<Plug>SneakNext" },
{ ",", "<Plug>SneakPrevious" },
},
},
{
"https://github.com/haya14busa/vim-asterisk", -- improved * search
keys = {
{ "*", "<Plug>(asterisk-z*)<Plug>(is-nohl-1)" },
{ "#", "<Plug>(asterisk-z#)<Plug>(is-nohl-1)" },
{ "g*", "<Plug>(asterisk-gz*)<Plug>(is-nohl-1)" },
{ "g#", "<Plug>(asterisk-gz#)<Plug>(is-nohl-1)" },
},
},
{
"https://github.com/andymass/vim-matchup", -- extended `%` jumping
keys = { "%" },
},
"https://github.com/wellle/targets.vim", -- extended motions `vin)`
{
"https://github.com/glts/vim-textobj-comment", -- comment textobj `vac`
dependencies = { "https://github.com/kana/vim-textobj-user" },
},
-- UI
{ "https://github.com/echasnovski/mini.indentscope", opts = {
symbol = "│",
} },
{
"https://github.com/nvim-lualine/lualine.nvim", -- fancy statusline
event = "VeryLazy",
dependencies = {
"https://github.com/nvim-tree/nvim-web-devicons",
"https://github.com/SmiteshP/nvim-navic",
"https://github.com/jcdickinson/wpm.nvim",
-- 'https://github.com/arkav/lualine-lsp-progress',
},
config = function()
local navic = require("nvim-navic")
navic.setup({
highlight = true,
separator = "  ",
-- separator = '  ',
lsp = {
auto_attach = true,
},
})
local wpm = require("wpm")
wpm.setup({})
require("lualine").setup({
options = {
disabled_filetypes = { statusline = { "alpha" } },
globalstatus = true,
-- section_separators = { left = '', right = '' },
-- component_separators = { left = '', right = '' },
},
extensions = {
"fzf",
"fugitive",
"nvim-tree",
"neo-tree",
"lazy",
},
sections = {
lualine_c = {
"filename",
{
-- navic.get_location, -- this seems like it would be equivalent
-- cond = navic.is_available, -- but it doesnt display anything
function()
return navic.get_location()
end,
cond = function()
return navic.is_available()
end,
},
},
lualine_x = {
function()
return wpm.wpm() .. " wpm" .. " " .. wpm.historic_graph()
end,
},
lualine_y = { "encoding", "fileformat" },
lualine_z = { "filetype" },
},
})
end,
},
{
"https://github.com/romgrk/barbar.nvim",
lazy = false,
dependencies = {
"https://github.com/lewis6991/gitsigns.nvim", -- OPTIONAL: for git status
"https://github.com/nvim-tree/nvim-web-devicons", -- OPTIONAL: for file icons
},
init = function()
vim.g.barbar_auto_setup = true
end,
keys = {
{ "[b", "<Cmd>BufferPrevious<CR>", desc = "Previous buffer in bar list", mode = "n", silent = true },
{ "]b", "<Cmd>BufferNext<CR>", desc = "Next buffer in bar list", mode = "n", silent = true },
{ "[B", "<Cmd>BufferMovePrevious<CR>", desc = "Next buffer in bar list", mode = "n", silent = true },
{ "]B", "<Cmd>BufferMoveNext<CR>", desc = "Next buffer in bar list", mode = "n", silent = true },
},
opts = {},
},
{
"https://github.com/nvim-neo-tree/neo-tree.nvim",
dependencies = {
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/nvim-tree/nvim-web-devicons",
"https://github.com/MunifTanjim/nui.nvim",
{ "https://github.com/miversen33/netman.nvim", opts = true },
},
lazy = true,
keys = {
{
"-",
"<Cmd>Neotree focus filesystem right reveal_force_cwd<CR>",
desc = "Show file in filetree",
mode = "n",
silent = true,
},
},
cmd = { "Neotree" },
opts = {
follow_current_file = { enabled = true },
popup_border_style = "rounded",
enable_git_status = true,
enable_diagnostics = false,
open_files_do_not_replace_types = { "terminal", "trouble", "qf" },
sources = {
"filesystem",
"buffers",
"document_symbols",
"git_status",
"netman.ui.neo-tree",
},
event_handlers = {
{
event = "file_opened",
handler = function(file_path)
require("neo-tree.command").execute({ action = "close" })
end,
},
},
document_symbols = {
follow_cursor = false,
},
-- Add this section only if you've configured source selector.
source_selector = {
-- winbar = true,
statusline = false,
sources = {
{ source = "document_symbols", display_name = " 󰌗 Symbols " },
{ source = "filesystem", display_name = " 󰉓 Files " },
{ source = "buffers", display_name = " 󰉓 Buffers " },
{ source = "git_status", display_name = " 󰊢 Git " },
},
},
filesystem = {
hijack_netrw_behavior = "open_default",
window = {
mappings = {
["-"] = "navigate_up",
},
},
},
default_component_configs = {
container = {
enable_character_fade = true,
},
indent = {
indent_size = 2,
padding = 1, -- extra padding on left hand side
-- indent guides
with_markers = true,
indent_marker = "│",
last_indent_marker = "└",
highlight = "NeoTreeIndentMarker",
-- expander config, needed for nesting files
with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
},
},
},
},
"https://github.com/noahfrederick/vim-noctu", -- a simple terminal-based theme
-- {
-- "https://github.com/flazz/vim-colorschemes", -- lots of colorschemes
-- priority = 100,
-- },
{ "https://github.com/catppuccin/nvim", name = "catppuccin", priority = 1000 },
{
"https://github.com/markonm/traces.vim", -- visual substitution highlight
},
{
"https://github.com/junegunn/goyo.vim", -- fences in current buffer with extra windows
keys = {
{ "<Leader>tG", "<Cmd>Goyo<CR>", desc = "Toggle Goyo", mode = "n", silent = true },
},
},
{
"https://github.com/junegunn/limelight.vim", -- helps focus on current paragraph
cmd = { "Limelight" },
lazy = true,
init = function()
vim.g.limelight_conceal_ctermfg = "black"
end,
keys = {
{ "<Leader>tl", "<Cmd>Limelight!!<CR>", mode = "n", desc = "Toggle limelight", silent = true },
},
},
{
"https://github.com/DanielFGray/DistractionFree.vim", -- toggle UI elements
keys = {
{ "<Leader>td", "<Cmd>DistractionsToggle<CR>", desc = "Toggle distractions", mode = "n", silent = true },
},
},
-- {
-- "https://github.com/anuvyklack/pretty-fold.nvim", -- prettier/configurable folds
-- opts = {
-- keep_indentation = true,
-- fill_char = " ",
-- process_comment_signs = true,
-- },
-- },
{
"https://github.com/goolord/alpha-nvim", -- fancy startup screen
dependencies = { "https://github.com/nvim-tree/nvim-web-devicons" },
config = function()
require("alpha").setup(require("alpha.themes.startify").config)
end,
},
{
"https://github.com/folke/which-key.nvim", -- visual keybind navigator
dependencies = { "https://github.com/afreakk/unimpaired-which-key.nvim" },
lazy = false,
keys = { "<leader>", "[", "]", "g", "v", "c", "d", "y", '"', "z", "<C-w>", "=", "@" },
config = function()
local wk = require("which-key")
wk.setup()
wk.add(require("unimpaired-which-key"))
end,
},
{
"https://github.com/lewis6991/gitsigns.nvim", -- git markers
event = { "BufReadPre", "BufNewFile" },
opts = {
current_line_blame = false,
signs = {
add = { text = "▎" },
change = { text = "▎" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "▎" },
untracked = { text = "▎" },
},
signs_staged = {
add = { text = "▎" },
change = { text = "▎" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "▎" },
},
preview_config = {
border = "single",
},
-- word_diff = true,
on_attach = function(bufnr)
local gitsigns = require("gitsigns")
vim.keymap.set("n", "[g", function()
gitsigns.nav_hunk("prev")
end, { buffer = bufnr, desc = "Jump to previous hunk" })
vim.keymap.set("n", "]g", function()
gitsigns.nav_hunk("next")
end, { buffer = bufnr, desc = "Jump to next hunk" })
vim.keymap.set("n", "<leader>gs", gitsigns.stage_hunk, { buffer = bufnr, desc = "Stage hunk" })
vim.keymap.set("n", "<leader>gr", gitsigns.reset_hunk, { buffer = bufnr, desc = "Reset hunk" })
vim.keymap.set("n", "<leader>gR", gitsigns.reset_buffer, { buffer = bufnr, desc = "Reset buffer" })
vim.keymap.set("n", "<leader>gp", gitsigns.preview_hunk, { buffer = bufnr, desc = "Preview hunk" })
vim.keymap.set(
"n",
"<leader>gb",
gitsigns.blame_line,
{ buffer = bufnr, desc = "Show blame information" }
)
vim.keymap.set(
"n",
"<leader>gS",
gitsigns.stage_buffer,
{ buffer = bufnr, desc = "Stage entire buffer" }
)
vim.keymap.set("n", "<leader>gD", gitsigns.diffthis, { buffer = bufnr, desc = "Diff buffer" })
vim.keymap.set(
"n",
"<leader>gT",
gitsigns.toggle_current_line_blame,
{ buffer = bufnr, desc = "Toggle current blame" }
)
vim.keymap.set("n", "<leader>gd", gitsigns.toggle_deleted, { buffer = bufnr, desc = "Toggle deleted" })
end,
},
},
{
"https://github.com/mbbill/undotree", -- visual undo tree
keys = {
{ "<Leader>u", "<Cmd>UndotreeToggle<CR>", desc = "Toggle undotree window", mode = "n", silent = true },
},
config = function()
vim.g.undotree_WindowLayout = 4
vim.g.undotree_SetFocusWhenToggle = 1
vim.g.undotree_SplitWidth = 60
vim.g.Undotree_CustomMap = function()
vim.keymap.set("n", "k", "<Plug>UndotreeGoNextState", { buffer = true, silent = true })
vim.keymap.set("n", "j", "<Plug>UndotreeGoPreviousState", { buffer = true, silent = true })
vim.keymap.set("n", "<Esc>", "<Plug>UndotreeClose", { buffer = true, silent = true })
end
end,
},
"https://github.com/sindrets/diffview.nvim",
{
"https://github.com/TimUntersberger/neogit", -- git integration
dependencies = {
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/sindrets/diffview.nvim",
},
cmd = { "Neogit" },
opts = {
kind = "split",
-- Persist the values of switches/options within and across sessions
remember_settings = true,
-- Scope persisted settings on a per-project basis
use_per_project_settings = false,
-- Array-like table of settings to never persist. Uses format 'Filetype--cli-value'
-- ie: `{ 'NeogitCommitPopup--author', 'NeogitCommitPopup--no-verify' }`
ignored_settings = {},
-- Change the default way of opening the commit popup
commit_popup = {
kind = "split",
},
-- Change the default way of opening the preview buffer
preview_buffer = {
kind = "split",
},
-- Change the default way of opening popups
popup = {
kind = "split",
},
-- customize displayed signs
signs = {
-- { CLOSED, OPENED },
section = { "󰜴", "󰜮" },
item = { "󰜴", "󰜮" },
hunk = { "", "" },
},
integrations = {
diffview = false,
},
-- Setting any section to `false` will make the section not render at all
sections = {
-- untracked = { folded = false },
-- unstaged = { folded = false },
-- staged = { folded = false },
-- stashes = { folded = true },
-- unpulled = { folded = true },
-- unmerged = { folded = false },
-- recent = { folded = true },
},
-- override/add mappings
mappings = {
-- modify status buffer mappings
-- status = {
-- -- Adds a mapping with 'B' as key that does the 'BranchPopup' command
-- ['B'] = 'BranchPopup',
-- -- Removes the default mapping of 's'
-- ['s'] = '',
-- },
},
},
},
{
"https://github.com/hkupty/iron.nvim", -- interactive repl
config = true,
lazy = true,
},
{
"https://github.com/kristijanhusak/vim-dadbod-ui", -- UI for interacting with a db
dependencies = {
"https://github.com/tpope/vim-dispatch",
"https://github.com/tpope/vim-dadbod",
},
keys = {
{ "<Leader>db", "<Cmd>DBUIToggle<CR>", desc = "open DB UI", mode = "n", silent = true },
{ "<Leader>db", "<Cmd>'<,'>DB<CR>", desc = "execute code", mode = "x", silent = true },
},
init = function()
vim.g.db_ui_env_variable_url = "DATABASE_URL"
vim.g.db_ui_hide_schemas = { "migrations", "information_schema", "pg_catalog" }
vim.g.db_ui_use_nerd_fonts = 1
vim.g.db_ui_table_helpers = {
postgresql = {
Count = "SELECT count(*) FROM {optional_schema}{table}",
Explain = "EXPLAIN ANALYZE\n{last_query}",
},
}
end,
},
{
"https://github.com/cshuaimin/ssr.nvim",
keys = {
{
"<Leader><C-s>",
function()
require("ssr").open()
end,
mode = { "n", "x" },
desc = "Structural replace",
silent = true,
},
},
opts = {
min_width = 50,
min_height = 5,
max_width = 120,
max_height = 25,
keymaps = {
close = "q",
next_match = "n",
prev_match = "N",
replace_confirm = "<CR>",
replace_all = "<Leader><CR>",
},
},
},
{
"https://github.com/gorbit99/codewindow.nvim", -- minimap
keys = {
{
"<Leader>tm",
function()
require("codewindow").toggle_minimap()
end,
mode = "n",
desc = "Toggle minimap",
silent = true,
},
},
config = function()
require("codewindow").setup({
exclude_filetypes = { "help", "NvimTree", "Trouble" },
window_border = "single",
})
vim.api.nvim_set_hl(0, "CodewindowBackground", { bg = "#222730" })
-- vim.api.nvim_set_hl(0, 'CodewindowError', { bg = '#ff0000' })
-- vim.api.nvim_set_hl(0, 'CodewindowWarn', { bg = '#ebcb8b' })
-- CodewindowAddition -- the color of the addition git sign
-- CodewindowDeletion -- the color of the deletion git sign
-- CodewindowUnderline -- the color of the underlines on the minimap
end,
},
{
"https://github.com/NvChad/nvim-colorizer.lua",
lazy = true,
opts = {
buftypes = {
"!prompt",
"!popup",
"!mason",
},
user_default_options = {
tailwind = true,
},
},
},
-- {
-- "https://github.com/folke/noice.nvim", -- "modernizes" neovim with popup command/search
-- event = "VeryLazy",
-- dependencies = {
-- -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
-- "https://github.com/MunifTanjim/nui.nvim",
-- {
-- "https://github.com/rcarriga/nvim-notify",
-- opts = {
-- render = "compact",
-- },
-- },
-- },
-- opts = {
-- lsp = {
-- progress = {
-- enabled = true,
-- },
-- hover = {
-- enabled = false,
-- },
-- signature = {
-- enabled = false,
-- },
-- },
-- presets = {
-- bottom_search = false, -- use a classic bottom cmdline for search
-- command_palette = true, -- position the cmdline and popupmenu together
-- long_message_to_split = true, -- long messages will be sent to a split
-- inc_rename = false, -- enables an input dialog for inc-rename.nvim
-- lsp_doc_border = true, -- add a border to hover docs and signature help
-- },
-- },
-- },
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
icons = vim.g.have_nerd_font and {} or {
cmd = "⌘",
config = "🛠",
event = "📅",
ft = "📂",
init = "⚙",
keys = "🗝",
plugin = "🔌",
runtime = "💻",
require = "🌙",
source = "📄",
start = "🚀",
task = "📌",
lazy = "💤 ",
},
},
})
vim.cmd([[ colorscheme catppuccin-macchiato ]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment