Skip to content

Instantly share code, notes, and snippets.

@joka90
Created December 12, 2022 10:23
Show Gist options
  • Save joka90/633505b4ed75c62dfb4f78d52b55e200 to your computer and use it in GitHub Desktop.
Save joka90/633505b4ed75c62dfb4f78d52b55e200 to your computer and use it in GitHub Desktop.
lvim config
--[[
lvim config for c++,c,cuda,cuda,bash,python
]]
vim.opt.backup = false -- creates a backup file
vim.opt.clipboard = "unnamedplus" -- allows neovim to access the system clipboard
vim.opt.cmdheight = 2 -- more space in the neovim command line for displaying messages
vim.opt.colorcolumn = "99999" -- fixes indentline for now
vim.opt.completeopt = { "menuone", "noselect" }
vim.opt.conceallevel = 0 -- so that `` is visible in markdown files
vim.opt.fileencoding = "utf-8" -- the encoding written to a file
vim.opt.foldmethod = "manual" -- folding set to "expr" for treesitter based folding
vim.opt.foldexpr = "" -- set to "nvim_treesitter#foldexpr()" for treesitter based folding
vim.opt.guifont = "monospace:h17" -- the font used in graphical neovim applications
vim.opt.hidden = true -- required to keep multiple buffers and open multiple buffers
vim.opt.hlsearch = true -- highlight all matches on previous search pattern
vim.opt.ignorecase = true -- ignore case in search patterns
vim.opt.mouse = "a" -- allow the mouse to be used in neovim
vim.opt.pumheight = 10 -- pop up menu height
vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore
vim.opt.showtabline = 2 -- always show tabs
vim.opt.smartcase = true -- smart case
vim.opt.smartindent = true -- make indenting smarter again
vim.opt.splitbelow = true -- force all horizontal splits to go below current window
vim.opt.splitright = true -- force all vertical splits to go to the right of current window
vim.opt.swapfile = false -- creates a swapfile
vim.opt.termguicolors = true -- set term gui colors (most terminals support this)
vim.opt.timeoutlen = 100 -- time to wait for a mapped sequence to complete (in milliseconds)
vim.opt.title = true -- set the title of window to the value of the titlestring
vim.opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
vim.opt.undodir = vim.fn.stdpath "cache" .. "/undo"
vim.opt.undofile = true -- enable persistent undo
vim.opt.updatetime = 300 -- faster completion
vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program) it is not allowed to be edited
vim.opt.expandtab = true -- convert tabs to spaces
vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation
vim.opt.tabstop = 2 -- insert 2 spaces for a tab
vim.opt.cursorline = true -- highlight the current line
vim.opt.number = true -- set numbered lines
vim.opt.relativenumber = false -- set relative numbered lines
vim.opt.numberwidth = 4 -- set number column width to 2 {default 4}
vim.opt.signcolumn = "yes" -- always show the sign column otherwise it would shift the text each time
vim.opt.wrap = false -- display lines as one long line
vim.opt.spell = false
vim.opt.spelllang = "en"
vim.opt.scrolloff = 8 -- is one of my fav
vim.opt.sidescrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.updatetime = 50
-- vim.opt.colorcolumn = "120"
-- vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.relativenumber = true
-- disable xclip
vim.opt.clipboard = "" -- "unnamedplus"
-- general
lvim.log.level = "warn"
lvim.format_on_save.enabled = false
lvim.colorscheme = "lunar"
-- to disable icons and use a minimalist setup, uncomment the following
-- lvim.use_icons = false
-- keymappings [view all the defaults by pressing <leader>Lk]
lvim.leader = "space"
-- add your own keymapping
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
-- lvim.keys.normal_mode["<S-l>"] = ":BufferLineCycleNext<CR>"
-- lvim.keys.normal_mode["<S-h>"] = ":BufferLineCyclePrev<CR>"
-- unmap a default keymapping
-- vim.keymap.del("n", "<C-Up>")
-- override a default keymapping
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" -- or vim.keymap.set("n", "<C-q>", ":q<cr>" )
local components = require("lvim.core.lualine.components")
lvim.builtin.lualine.sections.lualine_a = { "mode" }
-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode.
-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet.
local _, actions = pcall(require, "telescope.actions")
lvim.builtin.telescope.defaults.mappings = {
-- for input mode
i = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
},
-- for normal mode
n = {
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
}
-- require('telescope').load_extension('command_palette')
lvim.builtin.telescope.extensions.command_palette = {
{ "File",
{ "entire selection (C-a)", ':call feedkeys("GVgg")' },
{ "save current file (C-s)", ':w' },
{ "save all files (C-A-s)", ':wa' },
{ "quit (C-q)", ':qa' },
{ "file browser (C-i)", ":lua require'telescope'.extensions.file_browser.file_browser()", 1 },
{ "search word (A-w)", ":lua require('telescope.builtin').live_grep()", 1 },
{ "git files (A-f)", ":lua require('telescope.builtin').git_files()", 1 },
{ "files (C-f)", ":lua require('telescope.builtin').find_files()", 1 },
},
{ "Help",
{ "tips", ":help tips" },
{ "cheatsheet", ":help index" },
{ "tutorial", ":help tutor" },
{ "summary", ":help summary" },
{ "quick reference", ":help quickref" },
{ "search help(F1)", ":lua require('telescope.builtin').help_tags()", 1 },
},
{ "Vim",
{ "reload vimrc", ":source $MYVIMRC" },
{ 'check health', ":checkhealth" },
{ "jumps (Alt-j)", ":lua require('telescope.builtin').jumplist()" },
{ "commands", ":lua require('telescope.builtin').commands()" },
{ "command history", ":lua require('telescope.builtin').command_history()" },
{ "registers (A-e)", ":lua require('telescope.builtin').registers()" },
{ "colorshceme", ":lua require('telescope.builtin').colorscheme()", 1 },
{ "vim options", ":lua require('telescope.builtin').vim_options()" },
{ "keymaps", ":lua require('telescope.builtin').keymaps()" },
{ "buffers", ":Telescope buffers" },
{ "search history (C-h)", ":lua require('telescope.builtin').search_history()" },
{ "paste mode", ':set paste!' },
{ 'cursor line', ':set cursorline!' },
{ 'cursor column', ':set cursorcolumn!' },
{ "spell checker", ':set spell!' },
{ "relative number", ':set relativenumber!' },
{ "search highlighting (F12)", ':set hlsearch!' },
}
}
lvim.builtin.telescope.on_config_done = function(tele)
-- tele.load_extension("frecency")
tele.load_extension("command_palette")
tele.load_extension("aerial")
-- tele.load_extension("notify")
-- tele.load_extension("file_browser")
-- tele.load_extension("lazygit")
-- tele.load_extension("packer")
local opts = {
pickers = {
lsp_workspace_symbols = {
mappings = {
i = {
["<cr>"] = function(prompt_bufnr)
local selection = require("telescope.actions.state").get_selected_entry()
print(vim.inspect(selection))
end,
},
},
},
},
}
tele.setup(opts)
end
-- Change theme settings
-- lvim.builtin.theme.options.dim_inactive = true
-- lvim.builtin.theme.options.style = "storm"
-- Use which-key to add extra bindings with the leader-key prefix
lvim.builtin.which_key.mappings["w"] = {
"<cmd>lua require('window-picker').pick_window()<CR>", "Window picker"
}
-- vim.keymap.set("n", "<leader>w", function()
-- local picked_window_id = picker.pick_window() or vim.api.nvim_get_current_win()
-- vim.api.nvim_set_current_win(picked_window_id)
-- end, { desc = "Pick a window" })
-- lvim.builtin.which_key.mappings["p"] = {
-- name = "Packer",
-- c = { "<cmd>PackerCompile<cr>", "Compile" },
-- i = { "<cmd>PackerInstall<cr>", "Install" },
-- r = { "<cmd>LvimReload<cr>", "Reload" },
-- s = { "<cmd>PackerSync<cr>", "Sync" },
-- u = { "<cmd>PackerUpdate<cr>", "Update" },
-- }
lvim.builtin.which_key.mappings["D"] = lvim.builtin.which_key.mappings["d"]
lvim.builtin.which_key.mappings["t"] = {
name = "+Trouble",
r = { "<cmd>Trouble lsp_references<cr>", "References" },
f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
d = { "<cmd>Trouble document_diagnostics<cr>", "Diagnostics" },
q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
l = { "<cmd>Trouble loclist<cr>", "LocationList" },
w = { "<cmd>Trouble workspace_diagnostics<cr>", "Workspace Diagnostics" },
}
lvim.builtin.which_key.mappings["S"] = {
name = "Session",
c = { "<cmd>lua require('persistence').load()<cr>", "Restore last session for current dir" },
l = { "<cmd>lua require('persistence').load({ last = true })<cr>", "Restore last session" },
Q = { "<cmd>lua require('persistence').stop()<cr>", "Quit without saving session" },
}
-- https://github.com/nvim-telescope/telescope.nvim
-- TODO more https://github.com/nvim-telescope/telescope.nvim/wiki/Extensions
lvim.builtin.which_key.mappings["f"] = {
name = "Find",
o = { "<cmd>Telescope oldfiles<CR>", "Recent files" },
f = { "<cmd>Telescope current_buffer_fuzzy_find<CR>", "Fuzzy find" },
j = { "<cmd>Telescope jumplist<CR>", "Jumplist" },
a = { "<cmd>Telescope grep_string<CR>", "Find in Files" },
r = { "<cmd>Telescope resume<CR>", "Resume last picker" },
p = { "<cmd>Telescope pickers<CR>", "Choose and resume picker" },
P = { "<cmd>Telescope projects<CR>", "Projects" },
_ = { "<cmd>Telescope command_palette<CR>", "Command Palette" },
h = { "<cmd>Telescope history<CR>", "History" },
m = { "<cmd>Telescope man_pages<CR>", "Man pages" },
s = { "<cmd>Telescope lsp_document_symbols<CR>", "Lsp Document symbols" },
wo = { "<cmd>Telescope aerial<CR>", "Arial Document symbols" },
ws = { "<cmd>Telescope lsp_workspace_symbols<CR>", "Lsp Workspace symbols" },
t = { "<cmd>TodoTelescope<CR>", "Todo List"},
}
function _G.set_terminal_keymaps()
local opts = { buffer = 0 }
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
end
-- https://github.com/jesseduffield/lazydocker https://gist.github.com/ChristianChiarulli/9d1efc7d5c34443f7878e96998c9badf#file-which-key-vim-L205
lvim.builtin.which_key.mappings["v"] = {
name = "View",
t = { "<cmd>ToggleTerm direction=horizontal size=50 lua set_terminal_keymaps()<CR>", "Terminal" },
o = { "<cmd>AerialToggle right<CR>", "Show outline of file" },
q = { "<cmd>BqfToggle<CR>", "Better quickfix" },
m = { "<cmd>MiniMap.toggle<cr>", "MiniMap" },
d = { "<cmd>lua require('dapui').toggle()<cr>", "Debugger UI" },
g = { "<cmd>DiffviewOpen -uno<cr>", "DiffView files" },
b = { "<cmd>GitBlameToggle<cr>", "GitBlame" },
T = { "<cmd>TodoQuickFix<cr>", "TodoQuickFix" },
u = { "<cmd>UndotreeToggle<cr>", "Undotree" },
-- e = lvim.builtin.which_key.mappings["e"],
}
-- fix yank buffers
vim.keymap.set("x", "<leader>p", "\"_dP")
-- next greatest remap ever : asbjornHaland
vim.keymap.set("n", "<leader>y", "\"+y")
vim.keymap.set("v", "<leader>y", "\"+y")
vim.keymap.set("n", "<leader>Y", "\"+Y")
vim.keymap.set("n", "<leader>d", "\"_d")
vim.keymap.set("v", "<leader>d", "\"_d")
local undo_opts = { noremap = true, silent = true }
-- undo
vim.keymap.set("n", "<C-z>", "u", undo_opts)
vim.keymap.set("i", "<C-z>", "<C-o>u", undo_opts)
vim.keymap.set("v", "<C-z>", "<esc>u", undo_opts)
-- redo for normal mode is built-in
vim.keymap.set("i", "<C-r>", "<C-o><C-r>", undo_opts)
vim.keymap.set("v", "<C-r>", "<esc><C-r>", undo_opts)
local readline = require 'readline'
vim.keymap.set('!', '<M-f>', readline.forward_word)
vim.keymap.set('!', '<M-b>', readline.backward_word)
vim.keymap.set('!', '<C-a>', readline.beginning_of_line)
vim.keymap.set('!', '<C-e>', readline.end_of_line)
vim.keymap.set('!', '<M-d>', readline.kill_word)
vim.keymap.set('!', '<M-BS>', readline.backward_kill_word)
vim.keymap.set('!', '<C-w>', readline.unix_word_rubout)
vim.keymap.set('!', '<C-k>', readline.kill_line)
vim.keymap.set('!', '<C-u>', readline.backward_kill_line)
-- TODO: User Config for predefined plugins
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
lvim.builtin.alpha.active = true
lvim.builtin.alpha.mode = "dashboard"
lvim.builtin.terminal.active = true
lvim.builtin.nvimtree.setup.view.side = "left"
lvim.builtin.nvimtree.setup.renderer.icons.show.git = false
-- if you don't want all the parsers change this to a table of the ones you want
lvim.builtin.treesitter.ensure_installed = {
"bash",
"c",
"cpp",
"cuda",
"javascript",
"json",
"lua",
"python",
"css",
"rust",
"java",
"yaml",
"make",
"cmake",
}
lvim.builtin.treesitter.ignore_install = { "haskell" }
lvim.builtin.treesitter.highlight.enable = true
-- generic LSP settings
-- -- make sure server will always be installed even if the server is in skipped_servers list
lvim.lsp.installer.setup.ensure_insalled = {
"clang",
"cmake",
"dockerls",
"bashls",
}
-- -- set additional linters
local linters = require "lvim.lsp.null-ls.linters"
linters.setup {
-- { command = "flake8", filetypes = { "python" } },
{
-- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration
command = "shellcheck",
extra_args = { "--severity", "warning" },
},
}
-- Additional Plugins
-- https://github.com/rockerBOO/awesome-neovim
-- https://www.lunarvim.org/docs/plugins/core-plugins-list https://www.lunarvim.org/docs/plugins/extra-plugins
lvim.plugins = {
{
"folke/trouble.nvim",
cmd = "TroubleToggle",
},
{
"echasnovski/mini.map",
branch = "stable",
config = function()
require('mini.map').setup()
local map = require('mini.map')
map.setup({
integrations = {
map.gen_integration.builtin_search(),
map.gen_integration.diagnostic({
error = 'DiagnosticFloatingError',
warn = 'DiagnosticFloatingWarn',
info = 'DiagnosticFloatingInfo',
hint = 'DiagnosticFloatingHint',
}),
},
symbols = {
encode = map.gen_encode_symbols.dot('4x2'),
},
window = {
side = 'right',
width = 20, -- set to 1 for a pure scrollbar :)
winblend = 15,
show_integration_count = false,
},
})
end
},
{
"nacro90/numb.nvim",
event = "BufRead",
config = function()
require("numb").setup {
show_numbers = true, -- Enable 'number' for the window while peeking
show_cursorline = true, -- Enable 'cursorline' for the window while peeking
}
end,
},
{
's1n7ax/nvim-window-picker',
tag = 'v1.*',
config = function()
require 'window-picker'.setup()
end,
},
{
"kevinhwang91/nvim-bqf",
event = { "BufRead", "BufNew" },
config = function()
require("bqf").setup({
auto_enable = true,
preview = {
win_height = 12,
win_vheight = 12,
delay_syntax = 80,
border_chars = { "", "", "", "", "", "", "", "", "" },
},
func_map = {
vsplit = "",
ptogglemode = "z,",
stoggleup = "",
},
filter = {
fzf = {
action_for = { ["ctrl-s"] = "split" },
extra_opts = { "--bind", "ctrl-o:toggle-all", "--prompt", "> " },
},
},
})
end,
},
{
"rmagatti/goto-preview",
config = function()
require('goto-preview').setup {
width = 120; -- Width of the floating window
height = 25; -- Height of the floating window
default_mappings = false; -- Bind default mappings
debug = false; -- Print debug information
opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent.
post_open_hook = nil -- A function taking two arguments, a buffer and a window to be ran as a hook.
-- You can use "default_mappings = true" setup option
-- Or explicitly set keybindings
-- vim.cmd("nnoremap gpd <cmd>lua require('goto-preview').goto_preview_definition()<CR>")
-- vim.cmd("nnoremap gpi <cmd>lua require('goto-preview').goto_preview_implementation()<CR>")
-- vim.cmd("nnoremap gP <cmd>lua require('goto-preview').close_all_win()<CR>")
}
end
},
{
'weilbith/nvim-code-action-menu',
cmd = 'CodeActionMenu',
},
{
'simrat39/symbols-outline.nvim',
config = function()
require('symbols-outline').setup()
end
},
{
'ggandor/lightspeed.nvim',
event = "BufRead",
},
{
'chipsenkbeil/distant.nvim',
config = function()
require('distant').setup {
-- Applies Chip's personal settings to every machine you connect to
--
-- 1. Ensures that distant servers terminate with no connections
-- 2. Provides navigation bindings for remote directories
-- 3. Provides keybinding to jump into a remote file's parent directory
['*'] = require('distant.settings').chip_default()
}
end
},
{
'https://codeberg.org/esensar/nvim-dev-container',
requires = { 'nvim-treesitter/nvim-treesitter' }
},
{
"tpope/vim-fugitive",
cmd = {
"G",
"Git",
"Gdiffsplit",
"Gread",
"Gwrite",
"Ggrep",
"GMove",
"GDelete",
"GBrowse",
"GRemove",
"GRename",
"Glgrep",
"Gedit"
},
ft = { "fugitive" }
},
{
"folke/persistence.nvim",
event = "BufReadPre", -- this will only start session saving when an actual file was opened
module = "persistence",
config = function()
require("persistence").setup {
dir = vim.fn.expand(vim.fn.stdpath "config" .. "/session/"),
options = { "buffers", "curdir", "tabpages", "winsize" },
}
end,
},
{
"folke/todo-comments.nvim",
event = "BufRead",
config = function()
require("todo-comments").setup()
end,
},
{
'Civitasv/cmake-tools.nvim',
},
{
'linty-org/readline.nvim',
},
{
'mg979/vim-visual-multi',
},
{ "LinArcX/telescope-command-palette.nvim" },
{
'stevearc/aerial.nvim',
config = function() require('aerial').setup() end
},
{ 'sindrets/diffview.nvim', requires = 'nvim-lua/plenary.nvim' },
{
"f-person/git-blame.nvim",
event = "BufRead",
config = function()
vim.cmd "highlight default link gitblame SpecialComment"
vim.g.gitblame_enabled = 0
end,
},
{ -- run stuff that will polulate windo localtion list
"neomake/neomake",
},
{
"andythigpen/nvim-coverage",
requires = "nvim-lua/plenary.nvim",
config = function()
-- require("user.coverage")
end,
},
{
'vim-test/vim-test',
-- tag = "2.*",
branch = "master",
},
{ 'nvim-neotest/neotest-plenary' },
{ 'nvim-neotest/neotest-vim-test' },
{ 'nvim-neotest/neotest-python' },
{ -- TODO fix vim-test integration for ctest / make test
"nvim-neotest/neotest",
requires = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
"antoinemadec/FixCursorHold.nvim",
-- "vim-test/vim-test",
},
config = function()
require("neotest").setup({
adapters = { -- requires https://github.com/vim-test/vim-test/ to be installed
-- require("neotest-vim-test")({ allow_file_types = { "cpp", "c", "cuda" } }),
-- local status, plugin = pcall(require, 'neotest-vim-test')
-- if not status then
-- print('Something went wrong:', plugin)
-- else
-- plugin.setup({ allow_file_types = { "cpp", "c", "cuda" } })
-- end
require("neotest-python")({
dap = { justMyCode = false },
}),
require("neotest-plenary"),
require("neotest-vim-test")({
-- ignore_file_types = { "python", "vim", "lua" },
allow_file_types = { "haskell", "elixir", "cpp", "c", "cuda" }
}),
}
})
end,
}, -- https://github.com/Shatur/neovim-tasks to integrate kernel build system
{
"Shatur/neovim-tasks",
requires = {
"nvim-lua/plenary.nvim",
},
config = function()
require("tasks").setup({
}) -- TODO create custom tasks for debuild, Docker, make, kernel etc
end,
},
{ "JuliaEditorSupport/julia-vim", },
{
'gelguy/wilder.nvim',
config = function()
-- config goes here
local wilder = require('wilder')
wilder.setup({ modes = { ':', '/', '?' } })
wilder.set_option('pipeline', {
wilder.branch(
wilder.cmdline_pipeline(),
wilder.search_pipeline()
),
})
wilder.set_option('renderer', wilder.popupmenu_renderer({
highlighter = wilder.basic_highlighter(),
pumblend = 20,
left = { ' ', wilder.popupmenu_devicons() },
right = { ' ', wilder.popupmenu_scrollbar() },
}))
end,
},
{
'rcarriga/nvim-notify',
},
{'honza/vim-snippets'},
{'quangnguyen30192/cmp-nvim-ultisnips'}, -- TODO check that nvim-cmp finds this
{'SirVer/ultisnips'},
{'mbbill/undotree'},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment