-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT -- general lvim.format_on_save = true lvim.lint_on_save = true lvim.colorscheme = "onedarker" -- keymappings [view all the defaults by pressing Lk] lvim.leader = "space" vim.cmd [[let mapleader='\']] -- https://www.lunarvim.org/configuration/02-keybindings.html#lunarvim-keybindings -- use the default vim behavior for H and L lvim.keys.insert_mode[""] = nil lvim.keys.normal_mode[""] = nil lvim.keys.normal_mode[""] = nil -- add your own keymapping -- Emacs and bash style insert mode CTRL shortcuts lvim.keys.normal_mode["ZA"] = ":xa" lvim.keys.normal_mode["Y"] = "y$" -- = Move to start of the line; like in vim command mode: c_ctrl-b; To insert previously inserted text, use . or (below) lvim.keys.insert_mode[""] = "" -- = Move one character backward; the opposite of lvim.keys.insert_mode[""] = "" -- = Delete one character forward; the opposite of vim.cmd [[inoremap "\u"]] -- = Move to end of the line (already exists in command mode: c_ctrl-e), this also cancels completion lvim.keys.insert_mode[""] = "" -- = Move one character forward; the opposite of ; is too useful (for : / ?) to remap lvim.keys.insert_mode[""] = "" -- = Cancel completion vim.cmd [[inoremap pumvisible() ? "\" : ""]] -- = Delete one character backward; the opposite of ; already exists in command mode: c_ctrl-h vim.cmd [[inoremap "\u"]] -- = Delete to end of line; the opposite of ; https://www.reddit.com/r/vim/comments/9i58q8/question_re_delete_word_forward_in_insert_mode/e6he226/; https://superuser.com/a/855997 vim.cmd [[inoremap col(".") == col("$") ? "" : "d$"]] -- = make paste from register undoable in insert mode; already exists in command mode: c_ctrl-r vim.cmd [[inoremap "\u"]] -- = Delete to start of line; the opposite of ; already exists in command mode: c_ctrl-u vim.cmd [[inoremap "\u"]] -- = Delete word backward; opposite of ; same as ; already exists in command mode: c_ctrl-w vim.cmd [[inoremap "\u"]] -- = Paste from system clipboard (not from killring like in bash/emacs) vim.cmd [[inoremap "]] -- = Undo like in bash/emacs (this works really well) lvim.keys.insert_mode[""] = "u" -- = Undo like in bash/emacs (this works really well) lvim.keys.insert_mode[""] = "u" -- = Redo; opposite of lvim.keys.insert_mode[""] = "" -- = Move to previous sentence start ; opposite of lvim.keys.insert_mode[""] = "(" -- = Move one word backward; opposite of lvim.keys.insert_mode[""] = "" -- = Capitalize letter and move forward vim.cmd [[inoremap getline('.')[col('.')-1] =~ "\\s" ? "WgUllguwea" : "gUllguwea"]] -- = Delete word forward; opposite of and ; https://www.reddit.com/r/vim/comments/9i58q8/question_re_delete_word_forward_in_insert_mode/e6he226/ vim.cmd [[inoremap col(".") == col("$") ? "" : "de"]] -- = Move to previous sentence start ; opposite of lvim.keys.insert_mode[""] = ")" -- = Move one word forward; opposite of lvim.keys.insert_mode[""] = "" -- = Lowercase to word end; opposite of lvim.keys.insert_mode[""] = "gueea" -- = Uppercase to word end; opposite of lvim.keys.insert_mode[""] = "gUeea" -- = Insert Previously Inserted text (if any) lvim.keys.insert_mode[""] = "." -- 2-character Sneak (default) lvim.keys.normal_mode[""] = "Sneak_s" lvim.keys.normal_mode[""] = "Sneak_S" -- visual-mode lvim.keys.visual_mode[""] = "Sneak_s" lvim.keys.visual_mode[""] = "Sneak_S" -- repeat motion vim.cmd [[map ; Sneak_;]] vim.cmd [[map , Sneak_,]] -- 1-character enhanced 'f' vim.cmd [[nmap f Sneak_f]] vim.cmd [[nmap F Sneak_F]] -- visual-mode vim.cmd [[xmap f Sneak_f]] vim.cmd [[xmap F Sneak_F]] -- operator pending mode vim.cmd [[omap f Sneak_f]] vim.cmd [[omap F Sneak_F]] -- 1-character enhanced 't' vim.cmd [[nmap t Sneak_t]] vim.cmd [[nmap T Sneak_T]] -- visual-mode vim.cmd [[xmap t Sneak_t]] vim.cmd [[xmap T Sneak_T]] -- operator pending mode vim.cmd [[omap t Sneak_t]] vim.cmd [[omap T Sneak_T]] -- make vim-easymotion match spacemacs and doom emacs vim.cmd [[nmap gs (easymotion-prefix)]] vim.cmd [[xmap gsf (easymotion-f)]] vim.cmd [[omap gsf (easymotion-f)]] vim.cmd [[xmap gsF (easymotion-F)]] vim.cmd [[omap gsF (easymotion-F)]] vim.cmd [[xmap gst (easymotion-t)]] vim.cmd [[omap gst (easymotion-t)]] vim.cmd [[xmap gsT (easymotion-T)]] vim.cmd [[omap gsT (easymotion-T)]] vim.cmd [[xmap gsw (easymotion-w)]] vim.cmd [[omap gsw (easymotion-w)]] vim.cmd [[xmap gsW (easymotion-W)]] vim.cmd [[omap gsW (easymotion-W)]] vim.cmd [[xmap gsb (easymotion-b)]] vim.cmd [[omap gsb (easymotion-b)]] vim.cmd [[xmap gsB (easymotion-B)]] vim.cmd [[omap gsB (easymotion-B)]] vim.cmd [[xmap gse (easymotion-e)]] vim.cmd [[omap gse (easymotion-e)]] vim.cmd [[xmap gsE (easymotion-E)]] vim.cmd [[omap gsE (easymotion-E)]] vim.cmd [[xmap gsge (easymotion-ge)]] vim.cmd [[omap gsge (easymotion-ge)]] vim.cmd [[xmap gsgE (easymotion-gE)]] vim.cmd [[omap gsgE (easymotion-gE)]] vim.cmd [[xmap gsj (easymotion-j)]] vim.cmd [[omap gsj (easymotion-j)]] vim.cmd [[xmap gsk (easymotion-k)]] vim.cmd [[omap gsk (easymotion-k)]] vim.cmd [[xmap gsn (easymotion-n)]] vim.cmd [[omap gsn (easymotion-n)]] vim.cmd [[xmap gsN (easymotion-N)]] vim.cmd [[omap gsN (easymotion-N)]] vim.cmd [[xmap gss (easymotion-f2)]] vim.cmd [[omap gss (easymotion-f2)]] vim.cmd [[xmap gsS (easymotion-F2)]] vim.cmd [[omap gsS (easymotion-F2)]] vim.cmd [[vmap gy (Exchange)]] vim.cmd [[nmap gy (Exchange)]] -- https://github.com/unblevable/quick-scope#highlight-on-key-press -- vim.g.qs_highlight_on_keys = ['f', 'F', 't', 'T'] vim.g.EasyMotion_startofline = 0 -- keep cursor column when JK motion vim.g.EasyMotion_smartcase = 1 vim.g.EasyMotion_use_smartsign_us = 1 vim.g.textobj_entire_no_default_key_mappings = 1 lvim.keys.normal_mode["yog"] = ":Gitsigns toggle_signs" lvim.keys.normal_mode["yon"] = ":setlocal number!" lvim.keys.normal_mode["yor"] = ":setlocal relativenumber!" lvim.keys.normal_mode["yow"] = ":setlocal wrap!" vim.cmd [[nnoremap yoa &fo =~ 'a' ? ':set fo-=a' : ':set fo+=a']] vim.cmd [[onoremap ag (textobj-entire-a)]] vim.cmd [[onoremap ig (textobj-entire-i)]] vim.cmd [[xnoremap ag (textobj-entire-a)]] vim.cmd [[xnoremap ig (textobj-entire-i)]] -- https://www.lunarvim.org/configuration/02-keybindings.html#cursor-movement lvim.line_wrap_cursor_movement = true -- vim.opt.scrolloff = 0 -- Required so L moves to the last line -- lvim.keys.insert_mode[""] = "estrpart(getcmdline(),0,getcmdpos()-1)" -- unmap a default keymapping -- lvim.keys.normal_mode[""] = "" -- edit a default keymapping -- lvim.keys.normal_mode[""] = ":q" -- set keymap with custom opts -- lvim.keys.insert_mode["po"] = {'', { noremap = true }} -- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. -- lvim.builtin.telescope.on_config_done = function() -- local actions = require "telescope.actions" -- -- for input mode -- lvim.builtin.telescope.defaults.mappings.i[""] = actions.move_selection_next -- lvim.builtin.telescope.defaults.mappings.i[""] = actions.move_selection_previous -- lvim.builtin.telescope.defaults.mappings.i[""] = actions.cycle_history_next -- lvim.builtin.telescope.defaults.mappings.i[""] = actions.cycle_history_prev -- -- for normal mode -- lvim.builtin.telescope.defaults.mappings.n[""] = actions.move_selection_next -- lvim.builtin.telescope.defaults.mappings.n[""] = actions.move_selection_previous -- end -- Use which-key to add extra bindings with the leader-key prefix -- lvim.builtin.which_key.mappings["P"] = { "Telescope projects", "Projects" } -- lvim.builtin.which_key.mappings["t"] = { -- name = "+Trouble", -- r = { "Trouble lsp_references", "References" }, -- f = { "Trouble lsp_definitions", "Definitions" }, -- d = { "Trouble lsp_document_diagnostics", "Diagnosticss" }, -- q = { "Trouble quickfix", "QuickFix" }, -- l = { "Trouble loclist", "LocationList" }, -- w = { "Trouble lsp_workspace_diagnostics", "Diagnosticss" }, -- } -- Configure builtin plugins -- TODO: User Config for predefined plugins -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile -- lvim.builtin.dashboard.active = true lvim.builtin.terminal.active = true lvim.builtin.nvimtree.side = "left" -- lvim.builtin.nvimtree.show_icons.git = 0 -- Treesitter parsers change this to a table of the languages you want i.e. {"java", "python", javascript} -- lvim.builtin.treesitter.ensure_installed = "maintained" lvim.builtin.treesitter.ignore_install = { "haskell" } lvim.builtin.treesitter.highlight.enabled = true -- Disable virtual text -- lvim.lsp.diagnostics.virtual_text = false -- generic LSP settings -- you can set a custom on_attach function that will be used for all the language servers -- See -- lvim.lsp.on_attach_callback = function(client, bufnr) -- local function buf_set_option(...) -- vim.api.nvim_buf_set_option(bufnr, ...) -- end -- --Enable completion triggered by -- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- end -- you can overwrite the null_ls setup table (useful for setting the root_dir function) -- lvim.lsp.null_ls.setup = { -- root_dir = require("lspconfig").util.root_pattern("Makefile", ".git", "node_modules"), -- } -- or if you need something more advanced -- lvim.lsp.null_ls.setup.root_dir = function(fname) -- if vim.bo.filetype == "javascript" then -- return require("lspconfig/util").root_pattern("Makefile", ".git", "node_modules")(fname) -- or require("lspconfig/util").path.dirname(fname) -- elseif vim.bo.filetype == "php" then -- return require("lspconfig/util").root_pattern("Makefile", ".git", "composer.json")(fname) or vim.fn.getcwd() -- else -- return require("lspconfig/util").root_pattern("Makefile", ".git")(fname) or require("lspconfig/util").path.dirname(fname) -- end -- end -- set a formatter if you want to override the default lsp one (if it exists) -- lvim.lang.python.formatters = { -- { -- exe = "black", -- args = {} -- } -- } -- -- set an additional linter -- lvim.lang.python.linters = { -- { -- exe = "flake8", -- args = {} -- } -- } -- Additional Plugins lvim.plugins = { { "tpope/vim-fugitive", cmd = { "G", "Git", "Gdiffsplit", "Gread", "Gwrite", "Ggrep", "GMove", "GDelete", "GBrowse", "GRemove", "GRename", "Glgrep", "Gedit" }, ft = {"fugitive"} }, { "tpope/vim-surround", keys = {"c", "d", "y"} }, {"tpope/vim-speeddating"}, {"tpope/vim-repeat"}, {"tpope/vim-unimpaired"}, {"tommcdo/vim-exchange"}, {"inkarkat/vim-ReplaceWithRegister"}, {"unblevable/quick-scope"}, {"inkarkat/argtextobj.vim"}, {"michaeljsmith/vim-indent-object"}, {"kana/vim-textobj-entire"}, {"kana/vim-textobj-user"}, {'ntpeters/vim-better-whitespace'}, {"justinmk/vim-sneak"}, {"easymotion/vim-easymotion"}, {"ethanholz/nvim-lastplace"}, {"bronson/vim-visual-star-search"}, } -- https://github.com/ethanholz/nvim-lastplace require'nvim-lastplace'.setup { lastplace_ignore_buftype = {"quickfix", "nofile", "help"}, lastplace_ignore_filetype = {"gitcommit", "gitrebase", "svn", "hgcommit"}, lastplace_open_folds = true } -- Autocommands (https://neovim.io/doc/user/autocmd.html) -- https://www.lunarvim.org/docs/configuration/autocommands -- https://til.hashrocket.com/posts/17c44eda91-persistent-folds-between-vim-sessions vim.api.nvim_create_autocmd("BufWinLeave", { pattern = "*", command = "mkview", }) vim.api.nvim_create_autocmd("BufWinEnter", { pattern = "*", command = "silent! loadview", }) -- https://www.reddit.com/r/lunarvim/comments/10392z6/statusbar/ lvim.builtin.lualine.active = false lvim.builtin.bufferline.active = false lvim.builtin.breadcrumbs.active = false vim.opt.laststatus = 0 vim.opt.showtabline = 0 -- https://www.lunarvim.org/configuration/03-colorschemes.html#transparent-windows lvim.transparent_window = true -- https://www.lunarvim.org/configuration/01-settings.html#example-options vim.opt.cursorline = false -- don't highlight the current line vim.opt.cmdheight = 1 -- less space in the neovim command line for displaying messages vim.opt.number = false vim.opt.timeoutlen = 200 -- more time to wait for a mapped sequence to complete (in milliseconds)