Last active
July 19, 2022 04:52
-
-
Save nilium/db5b4e57ff694b94164dc0e4d7af1c10 to your computer and use it in GitHub Desktop.
LunarVim config, similar to my personal vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
lvim is the global options object | |
After changing plugin config exit and reopen LunarVim, then run | |
:PackerInstall and :PackerCompile. Sometimes it's also necessary to delete | |
~/.config/lvim/plugin/packer_compiled.lua and run :PackerSync. | |
]] | |
-- general | |
lvim.log.level = "warn" | |
lvim.format_on_save = true | |
lvim.colorscheme = "kanagawa" | |
-- to disable icons and use a minimalist setup, uncomment the following | |
lvim.use_icons = false | |
vim.o.modeline = false | |
vim.o.synmaxcol = 400 -- Bail on too much work for syntax highlighting. | |
-- Keyboard timeouts. | |
vim.o.timeoutlen = 200 | |
vim.o.ttimeoutlen = 200 | |
-- Misc stuff from vimrc | |
vim.o.undolevels = 2000 | |
vim.o.joinspaces = false | |
vim.o.wildmenu = true | |
vim.o.showcmd = true | |
vim.o.showmode = true | |
vim.o.wildignore = "*/node_modules/*,*.so,*.swp,*/.git/*,*.zip,*.dmg,*/*.sparsebundle/*" | |
vim.o.splitright = true | |
vim.o.splitbelow = true | |
vim.o.autoindent = true | |
vim.o.smarttab = true | |
vim.o.expandtab = false | |
vim.o.shiftwidth = 8 | |
vim.o.tabstop = 8 | |
vim.o.softtabstop = 8 | |
vim.o.textwidth = 120 | |
-- For some reason LunarVim makes Vim's default visual mode behavior of | |
-- selecting the end of a line not work, and I haven't figure out why. For now, | |
-- turn on virtualedit / selection to emulate it. | |
vim.o.virtualedit = 'block,onemore' | |
vim.o.selection = 'inclusive' | |
vim.o.whichwrap = 'b,s' | |
vim.o.listchars = 'tab:│·,trail:·,extends:→,precedes:←,nbsp:·' | |
vim.o.list = false | |
vim.o.ruler = true | |
vim.o.number = true | |
vim.o.relativenumber = true | |
-- Disable unwanted builtins | |
lvim.builtin.alpha.active = false | |
lvim.builtin.telescope.active = false | |
lvim.builtin.notify.active = true | |
lvim.builtin.terminal.active = false | |
lvim.builtin.nvimtree.active = false | |
lvim.builtin.project.active = false | |
lvim.builtin.dap.active = false | |
-- Cmp | |
lvim.builtin.cmp.experimental.ghost_text = false | |
-- Bufferline config | |
lvim.builtin.bufferline.options.show_close_icon = false | |
lvim.builtin.bufferline.options.show_buffer_close_icons = false | |
lvim.builtin.bufferline.options.separator_style = 'thin' | |
lvim.builtin.bufferline.options.always_show_bufferline = true | |
-- Please, for the love of god, just always show me the buffer number. | |
lvim.builtin.bufferline.options.name_formatter = function(buf) | |
return buf.bufnr .. ": " .. buf.name | |
end | |
lvim.builtin.bufferline.options.number = function(num) | |
-- { ordinal, id, lower, raise } | |
return num.ordinal .. "/" .. num.id | |
end | |
-- if you don't want all the parsers change this to a table of the ones you want | |
lvim.builtin.treesitter.ignore_install = { "haskell" } | |
lvim.builtin.treesitter.highlight.enabled = true | |
lvim.builtin.treesitter.rainbow.enable = true | |
lvim.builtin.treesitter.ensure_installed = { | |
"bash", | |
"c", | |
"javascript", | |
"json", | |
"lua", | |
"python", | |
"css", | |
"rust", | |
"ruby", | |
"yaml", | |
"go", | |
} | |
-- keymappings [view all the defaults by pressing <leader>Lk] | |
-- add your own keymapping | |
lvim.leader = "," | |
-- lvim.leader does not immediately set <Leader> (a little surprised it's not | |
-- a metatable or something), so set it here as well. | |
vim.o.leader = "," | |
-- NOTE: lvim.keys.* does not use metatables, assignments do not immediately | |
-- take effect, so what <Leader> means to this is whatever the *last* value of | |
-- lvim.leader is. To use <Leader> immediately, set vim.o.leader and use | |
-- nvim_set_keymap. | |
-- Old formatting keys | |
lvim.keys.normal_mode['<Leader>=i'] = { 'mzvip=`z', { noremap = true } } -- Format paragraph with =. | |
lvim.keys.normal_mode['<Leader>=g'] = { 'mzgg=G`z', { noremap = true } } -- Format buffer with =. | |
lvim.keys.normal_mode['<Leader>wi'] = { 'mzgqip`z', { noremap = true } } -- Foramt paragraph with gq. | |
lvim.keys.normal_mode['<Leader>wg'] = { 'mzgggqG`z', { noremap = true } } -- Format document with gq. | |
-- Reset hlsearch | |
lvim.keys.normal_mode['<Leader><Leader>'] = { ":nohlsearch<CR>:echo ''<CR>", { noremap = true } } | |
-- Toggles | |
lvim.keys.normal_mode['<Leader>sl'] = { '<Cmd>set list!<CR>', { noremap = true } } | |
lvim.keys.normal_mode['<Leader>sw'] = { '<Cmd>set wrap!<CR>', { noremap = true } } | |
lvim.keys.normal_mode['<Leader>sr'] = { '<Cmd>set relativenumber!<CR>', { noremap = true } } | |
-- Buffers | |
lvim.keys.normal_mode['<Leader>bn'] = { '<Cmd>bnext<CR>', { noremap = true } } | |
lvim.keys.normal_mode['<Leader>bp'] = { '<Cmd>bprev<CR>', { noremap = true } } | |
lvim.keys.normal_mode['<Leader>q'] = { '<Cmd>Bdelete<CR>', { noremap = true } } | |
-- Switch to buffer given by count. | |
-- vim.cmd("nnoremap <silent> <expr> ,b (v:count > 0 ? ':b'.v:count : ':ls').'<CR>'") | |
-- Emacs keys | |
lvim.keys.normal_mode['<C-a>'] = { '^', { noremap = true } } | |
lvim.keys.normal_mode['<C-e>'] = { '$', { noremap = true } } | |
lvim.keys.visual_mode['<C-a>'] = { '^', { noremap = true } } | |
lvim.keys.visual_mode['<C-e>'] = { '$', { noremap = true } } | |
lvim.keys.insert_mode['<C-a>'] = { '<C-o>^', { noremap = true } } | |
lvim.keys.insert_mode['<C-e>'] = { '<C-o>$', { noremap = true } } | |
-- Operator waiting mode, oddly missing in lvim.keys. | |
vim.cmd('onoremap <silent> <C-a> ^') | |
vim.cmd('onoremap <silent> <C-e> $') | |
-- Fzf | |
lvim.keys.normal_mode['<Leader>t'] = { '<Cmd>FzfFiles<CR>', { noremap = true } } | |
lvim.keys.normal_mode['<Leader>b'] = { '<Cmd>FzfBuffers<CR>', { noremap = true } } | |
lvim.keys.normal_mode['<Leader>r'] = { '<Cmd>FzfRg<CR>', { noremap = true } } | |
lvim.keys.normal_mode['<Leader>c'] = { '<Cmd>FzfCommands<CR>', { noremap = true } } | |
-- Disable A-up/down for moving lines up/down, A-left/right, A-[jk], and jk. | |
for i, dir in ipairs({ "<A-Up>", "<A-Down>", "<A-Left>", "<A-Right>", "<A-j>", "<A-k>", "jk", "jj", "kj", "$", "^" }) do | |
lvim.keys.insert_mode[dir] = false | |
lvim.keys.normal_mode[dir] = false | |
lvim.keys.visual_mode[dir] = false | |
end | |
-- Disable LunarVim's sticky visual shift. They call it better, I disagree. | |
lvim.keys.visual_mode['>'] = false | |
lvim.keys.visual_mode['<'] = false | |
-- Disable telescope binding that doesn't get removed by default. | |
lvim.keys.normal_mode['<Leader>f'] = false | |
-- undotree -- feels like there should be a way to set this in a config function | |
-- but it didn't work and I'm not trying that hard. | |
lvim.keys.normal_mode['<Leader>u'] = { '<Cmd>UndotreeToggle<CR>', { noremap = true } } | |
-- A handful of special bindings for jumping up/down visually in wrapped text. | |
-- Pretty much makes j/k move up and down visually. This might work better if it | |
-- checked if wrap was set, but is it necessary? Nah. | |
vim.cmd("vnoremap <silent> <expr> j (v:count > 3 ? \"m'\" .. v:count . 'j' : 'gj')") | |
vim.cmd("vnoremap <silent> <expr> k (v:count > 3 ? \"m'\" .. v:count . 'k' : 'gk')") | |
vim.cmd("nnoremap <silent> <expr> j (v:count > 3 ? \"m'\" .. v:count . 'j' : 'gj')") | |
vim.cmd("nnoremap <silent> <expr> k (v:count > 3 ? \"m'\" .. v:count . 'k' : 'gk')") | |
-- Yanky | |
vim.api.nvim_set_keymap("n", "p", "<Plug>(YankyPutAfter)", { noremap = true }) | |
vim.api.nvim_set_keymap("n", "P", "<Plug>(YankyPutBefore)", { noremap = true }) | |
vim.api.nvim_set_keymap("x", "p", "<Plug>(YankyPutAfter)", { noremap = true }) | |
vim.api.nvim_set_keymap("x", "P", "<Plug>(YankyPutBefore)", { noremap = true }) | |
vim.api.nvim_set_keymap("n", "gp", "<Plug>(YankyGPutAfter)", { noremap = true }) | |
vim.api.nvim_set_keymap("n", "gP", "<Plug>(YankyGPutBefore)", { noremap = true }) | |
vim.api.nvim_set_keymap("x", "gp", "<Plug>(YankyGPutAfter)", { noremap = true }) | |
vim.api.nvim_set_keymap("x", "gP", "<Plug>(YankyGPutBefore)", { noremap = true }) | |
vim.api.nvim_set_keymap("n", "<c-n>", "<Plug>(YankyCycleForward)", { noremap = true }) | |
vim.api.nvim_set_keymap("n", "<c-p>", "<Plug>(YankyCycleBackward)", { noremap = true }) | |
-- Stamp | |
lvim.keys.normal_mode['S'] = '<Cmd>lua require("stamp").stamp(vim.v.register)<CR>' | |
-- Additional Plugins | |
lvim.plugins = { | |
-- My personal plugins. | |
{ | |
"nilium/nil.nvim", | |
}, | |
-- My fork of Smart-Tabs to fix some quirks around indentation handling. | |
{ | |
"nilium/Smart-Tabs", | |
config = function() | |
vim.g.ctab_disable_checkalign = 1 | |
end, | |
}, | |
-- :Bdelete | |
{ "moll/vim-bbye" }, | |
-- The Tim Pope collection | |
{ | |
"tpope/vim-commentary", | |
-- Disabled while LunarVim comment plugin is installed. May put this back | |
-- in later. | |
disable = lvim.builtin.comment.active | |
}, | |
{ "tpope/vim-sleuth" }, | |
{ "tpope/vim-surround" }, | |
{ "tpope/vim-unimpaired" }, | |
{ "tpope/vim-repeat" }, | |
-- Register peeking via " | |
{ "junegunn/vim-peekaboo" }, | |
-- :Tabularize. | |
{ "godlygeek/tabular" }, | |
-- jq syntax. | |
{ "vito-c/jq.vim" }, | |
-- Undo graph visualization, replaces Gundo. | |
{ "mbbill/undotree" }, | |
-- Rainbow brackets, everyone's favorite plugin. | |
{ "p00f/nvim-ts-rainbow" }, | |
-- Highlight word under cursor. | |
{ | |
"itchyny/vim-cursorword", | |
event = { "BufEnter", "BufNewFile" }, | |
config = function() | |
vim.api.nvim_command("augroup user_plugin_cursorword") | |
vim.api.nvim_command("autocmd!") | |
vim.api.nvim_command("autocmd FileType NvimTree,lspsagafinder,dashboard,vista let b:cursorword = 0") | |
vim.api.nvim_command("autocmd WinEnter * if &diff || &pvw | let b:cursorword = 0 | endif") | |
vim.api.nvim_command("autocmd InsertEnter * let b:cursorword = 0") | |
vim.api.nvim_command("autocmd InsertLeave * let b:cursorword = 1") | |
vim.api.nvim_command("augroup END") | |
end | |
}, | |
-- Highlight TODO, WARN, etc. comments. | |
-- Doesn't handle TODO(ncower) and so on, and updating the pattern it uses to | |
-- include those renders poorly, so may do this differently later. | |
{ | |
"folke/todo-comments.nvim", | |
event = "BufRead", | |
config = function() | |
require("todo-comments").setup {} | |
end, | |
}, | |
-- Put function context at top of screen if it goes outside the window at the | |
-- top. No effect on bottom. | |
{ | |
"romgrk/nvim-treesitter-context", | |
config = function() | |
require("treesitter-context").setup { | |
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) | |
throttle = true, -- Throttles plugin updates (may improve performance) | |
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. | |
patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries. | |
-- For all filetypes | |
-- Note that setting an entry here replaces all other patterns for this entry. | |
-- By setting the 'default' entry below, you can control which nodes you want to | |
-- appear in the context window. | |
default = { | |
'class', | |
'function', | |
'method', | |
}, | |
}, | |
} | |
end | |
}, | |
-- Signature float: | |
{ | |
"ray-x/lsp_signature.nvim", | |
event = "BufRead", | |
config = function() require "lsp_signature".on_attach() end, | |
}, | |
-- Indent guides: | |
{ | |
"lukas-reineke/indent-blankline.nvim", | |
event = "BufRead", | |
setup = function() | |
vim.g.indentLine_enabled = 1 | |
vim.g.indent_blankline_char = "▏" | |
vim.g.indent_blankline_filetype_exclude = { "help", "terminal", "dashboard" } | |
vim.g.indent_blankline_buftype_exclude = { "terminal" } | |
vim.g.indent_blankline_show_trailing_blankline_indent = false | |
vim.g.indent_blankline_show_first_indent_level = false | |
end | |
}, | |
-- rust-analyzer additions: | |
{ -- For inlay hints: | |
"simrat39/rust-tools.nvim", | |
-- branch = "modularize_and_inlay_rewrite", | |
config = function() | |
require('rust-tools').setup {} | |
end | |
}, | |
-- YankRing replacement: | |
{ | |
"gbprod/yanky.nvim", | |
config = function() | |
require("yanky").setup {} | |
end, | |
}, | |
-- fzf | |
{ | |
"junegunn/fzf" | |
}, | |
{ | |
"junegunn/fzf.vim", | |
require = { "junegunn/fzf" }, | |
setup = function() | |
vim.g.fzf_command_prefix = 'Fzf' | |
vim.env.FZF_DEFAULT_COMMAND = 'fd -tf' | |
end, | |
}, | |
-- Color scheme | |
{ | |
"rebelot/kanagawa.nvim", | |
config = function() | |
-- Tweak colors to resemble triplejelly, since I don't feel like updating | |
-- the hightlight groups for it to match all of Treesitter. | |
local colors = { | |
bg = '#040404', | |
fg = '#C6CFD2', | |
fg_comment = '#74737E', | |
kw = '#DBCD5D', | |
st = '#BBE16C', | |
fn = '#00D2E5', | |
id = '#47AEE8', | |
ns = '#FB97D2', | |
nu = '#99CC66', | |
ty = '#FB97D2', | |
tb = '#EC7967', | |
inc = '#E160B4', | |
macro = '#BB95EF', | |
cursorline = '#202026', | |
cursorlinenr = '#4a4a5a', | |
context = '#294d49', | |
} | |
colors.sp2 = colors.tb | |
colors.pp = colors.macro | |
colors.br = colors.fg | |
local overrides = { | |
CursorLine = { bg = colors.cursorline }, | |
LineNr = { fg = colors.cursorline }, | |
CursorLineNr = { fg = colors.cursorlinenr }, | |
MatchParen = { fg = colors.kw, bg = '', underline = true }, | |
Include = { fg = colors.inc }, | |
Macro = { fg = colors.macro }, | |
Namespace = { fg = colors.ns }, | |
Variable = { fg = colors.id }, | |
TSConstMacro = { link = 'Macro' }, | |
TSField = { fg = colors.fg }, | |
TSFuncMacro = { link = 'Macro' }, | |
TSInclude = { link = 'Include' }, | |
TSNamespace = { link = 'Namespace' }, | |
TSTypeBuiltin = { fg = colors.tb }, | |
TSVariable = { link = 'Variable' }, | |
TSConstructor = { fg = colors.fg }, | |
TreesitterContext = { bg = colors.context }, | |
TreesitterContextLineNumber = { fg = colors.context }, | |
} | |
require('kanagawa').setup({ | |
undercurl = true, -- enable undercurls | |
commentStyle = { italic = false }, | |
functionStyle = {}, | |
keywordStyle = { italic = false }, | |
statementStyle = { bold = false }, | |
typeStyle = {}, | |
variablebuiltinStyle = { italic = false }, | |
specialReturn = true, -- special highlight for the return keyword | |
specialException = true, -- special highlight for exception handling keywords | |
transparent = false, -- do not set background color | |
dimInactive = false, -- dim inactive window `:h hl-NormalNC` | |
globalStatus = false, -- adjust window separators highlight for laststatus=3 | |
terminalColors = true, -- define vim.g.terminal_color_{0,17} | |
colors = colors, | |
overrides = overrides, | |
}) | |
-- If I don't add this here, LunarVim fails to correctly set the | |
-- colorscheme. No idea why. Not interested in debugging it -- the way it | |
-- handles color schemes is super broken already. | |
vim.cmd({ cmd = "colorscheme", args = { "kanagawa" } }) | |
end, | |
}, | |
-- Color scheme debugging | |
{ | |
-- Treesitter playground -- enable for grabbing treesitter highlight groups | |
-- with :TSHighlightCapturesUnderCursor. | |
"nvim-treesitter/playground", | |
disable = true | |
}, | |
-- Fennel | |
{ | |
"rktjmp/hotpot.nvim", | |
config = function() | |
require("hotpot").setup { | |
provide_require_fennel = true, | |
enable_hotpot_diagnostics = true, | |
compiler = { | |
modules = { | |
correlate = true, | |
}, | |
macros = { | |
env = "_COMPILER", | |
}, | |
}, | |
} | |
end, | |
}, | |
-- Fennel highlighting | |
{ | |
"jaawerth/fennel.vim" | |
}, | |
-- Parinfer | |
{ | |
"eraserhd/parinfer-rust", | |
fg = { 'scheme', 'chicken', 'clojure', 'lisp' }, | |
run = 'cargo build --release', | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment