--[[ lvim is the global options object Linters should be filled in as strings with either a global executable or a path to an executable ]] -- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT -- vim.cmd [[set nomodeline]] -- vim.cmd [[set modelines=0]] -- general lvim.log.level = "warning" lvim.format_on_save = false lvim.colorscheme = "space-vim-dark" vim.lsp.set_log_level("debug") local tables = { "clangd" } vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, tables, 1, #tables) vim.list_extend(lvim.lsp.override, tables, 1, #tables) local clangd_bin = "clangd" -- local clangd_flags = { -- "--query-driver=/usr/bin/arm-none-eabi*", -- "--background-index", "--pch-storage=memory", "-j=4", "--log=verbose", -- -- "--path-mappings=/from=/to", -- } local clangd_flags = { "--query-driver=/usr/bin/g++-12", "--background-index", "--pch-storage=memory", "-j=4", "--log=verbose", -- "--path-mappings=/from=/to", } -- Example local custom_on_attach = function(client, bufnr) require("lvim.lsp").common_on_attach(client, bufnr) local opts = { noremap = true, silent = true } vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "lua vim.lsp.buf.implementation()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "", "lua vim.lsp.buf.signature_help()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) vim.api.nvim_buf_set_keymap(bufnr, "n", "lh", "ClangdSwitchSourceHeader", opts) vim.api.nvim_buf_create_user_command(bufnr, 'FormatRegion', function(_opts) local format_opts = { async = false} if _opts.range > 0 then format_opts.range = { { _opts.line1, 0 }, { _opts.line2, 0 }, } end vim.lsp.buf.format(format_opts) end, { range = true }) end local opts = { cmd = { clangd_bin, unpack(clangd_flags) }, on_attach = custom_on_attach, } require("lvim.lsp.manager").setup("clangd", opts) -- keymappings [view all the defaults by pressing Lk] lvim.leader = "space" lvim.keys.normal_mode[""] = ":w" lvim.builtin.terminal.open_mapping = [[]] lvim.builtin.terminal.direction = "horizontal" local keymap_opts = { noremap = true, silent = true } vim.api.nvim_set_keymap("v", "p", '"_dP', keymap_opts) -- unmap a default keymapping -- lvim.keys.normal_mode[""] = false -- edit a default keymapping -- lvim.keys.normal_mode[""] = ":q" -- 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 = { -- [""] = actions.move_selection_next, -- [""] = actions.move_selection_previous, -- [""] = actions.cycle_history_next, -- [""] = actions.cycle_history_prev, -- }, -- -- for normal mode -- n = { -- [""] = actions.move_selection_next, -- [""] = actions.move_selection_previous, -- }, -- } lvim.builtin.which_key.mappings["G"] = { "Glow", "Markdown Preview" } lvim.builtin.which_key.vmappings["f"] = { "FormatRegion", "Format Region", } -- Telescope lvim.builtin.which_key.mappings["f"] = { name = "+Finder", f = { "Telescope find_files", "Find files" }, g = { "Telescope live_grep", "Live Grep" } } lvim.builtin.which_key.mappings["t"] = { name = "+Trouble", r = { "Trouble lsp_references", "References" }, f = { "Trouble lsp_definitions", "Definitions" }, d = { "Trouble document_diagnostics", "Diagnostics" }, q = { "Trouble quickfix", "QuickFix" }, l = { "Trouble loclist", "LocationList" }, w = { "Trouble workspace_diagnostics", "Wordspace Diagnostics" }, } lvim.builtin.which_key.mappings["w"] = { name = "+Window", [""] = { "h", "Jump to Left Buffer" }, [""] = { "j", "Jump to Below Buffer" }, [""] = { "k", "Jump to Above Buffer" }, [""] = { "l", "Jump to Right Buffer" }, h = { ":bprevious", "Previous buffer tab" }, l = { ":bnext", "Next buffer tab" }, x = { "BufferKill", "Close Buffer" } } -- 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.bufferline.options.close_command = ":BufDel %d" lvim.builtin.terminal.active = true lvim.builtin.nvimtree.setup.view.side = "left" -- lvim.builtin.nvimtree.show_icons.git = 0 -- 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", "javascript", "json", "lua", "python", "typescript", "tsx", "css", "rust", "java", "yaml", } lvim.builtin.treesitter.ignore_install = { "haskell" } lvim.builtin.treesitter.highlight.enabled = true lvim.builtin.treesitter.rainbow.enable = true lvim.builtin.treesitter.indent = false lvim.lsp.diagnostics.virtual_text = false -- generic LSP settings -- ---@usage disable automatic installation of servers -- lvim.lsp.automatic_servers_installation = false -- ---@usage Select which servers should be configured manually. Requires `:LvimCacheReset` to take effect. -- See the full default list `:lua print(vim.inspect(lvim.lsp.override))` -- vim.list_extend(lvim.lsp.override, { "pylsp" }) -- ---@usage setup a server -- see: https://www.lunarvim.org/languages/#overriding-the-default-configuration -- local opts = {} -- check the lspconfig documentation for a list of all possible options -- require("lvim.lsp.manager").setup("pylsp", opts) -- -- 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 -- -- set a formatter, this will override the language server formatting capabilities (if it exists) -- local formatters = require "lvim.lsp.null-ls.formatters" -- formatters.setup { -- { command = "black", filetypes = { "python" } }, -- { command = "isort", filetypes = { "python" } }, -- { -- -- each formatter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration -- command = "prettier", -- ---@usage arguments to pass to the formatter -- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}` -- extra_args = { "--print-with", "100" }, -- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. -- filetypes = { "typescript", "typescriptreact" }, -- }, -- } -- -- 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", -- ---@usage arguments to pass to the formatter -- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}` -- extra_args = { "--severity", "warning" }, -- }, -- { -- command = "codespell", -- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. -- filetypes = { "javascript", "python" }, -- }, -- } -- Additional Plugins lvim.plugins = { { "liuchengxu/space-vim-dark" }, { "p00f/nvim-ts-rainbow" }, { "folke/trouble.nvim", cmd = "TroubleToggle", }, { "ellisonleao/glow.nvim" }, { "TimUntersberger/neogit", requires = "nvim-lua/plenary.nvim", requires = "sindrets/diffview.nvim", require('neogit').setup { disable_signs = false, disable_hint = false, disable_context_highlighting = false, disable_commit_confirmation = false, auto_refresh = true, disable_builtin_notifications = false, use_magit_keybindings = false, kind = "tab", console_timeout = 2000, auto_show_console = true, commit_popup = { kind = "split", }, popup = { kind = "split", }, signs = { -- { CLOSED, OPENED } section = { ">", "v" }, item = { ">", "v" }, hunk = { "", "" }, }, integrations = { diffview = true }, 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"] = "", } } } }, { "sindrets/diffview.nvim", requires = "nvim-lua/plenary.nvim", }, } -- lvim.plugins = { -- {"folke/tokyonight.nvim"}, -- { -- "folke/trouble.nvim", -- cmd = "TroubleToggle", -- }, -- } -- Autocommands (https://neovim.io/doc/user/autocmd.html) -- lvim.autocommands.custom_groups = { -- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, -- } local options = { backup = true, -- creates a backup file clipboard = "unnamedplus", -- allows neovim to access the system clipboard cmdheight = 2, -- more space in the neovim command line for displaying messages completeopt = { "menuone", "noselect" }, -- mostly just for cmp conceallevel = 0, -- so that `` is visible in markdown files fileencoding = "utf-8", -- the encoding written to a file hlsearch = true, -- highlight all matches on previous search pattern ignorecase = true, -- ignore case in search patterns mouse = "a", -- allow the mouse to be used in neovim pumheight = 10, -- pop up menu height showmode = false, -- we don't need to see things like -- INSERT -- anymore showtabline = 2, -- always show tabs smartcase = true, -- smart case smartindent = false, -- make indenting smarter again splitbelow = true, -- force all horizontal splits to go below current window splitright = true, -- force all vertical splits to go to the right of current window swapfile = true, -- creates a swapfile termguicolors = true, -- set term gui colors (most terminals support this) timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds) undofile = true, -- enable persistent undo updatetime = 300, -- faster completion (4000ms default) 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 expandtab = false, -- convert tabs to spaces shiftwidth = 4, -- the number of spaces inserted for each indentation tabstop = 4, -- insert 2 spaces for a tab cursorline = true, -- highlight the current line number = true, -- set numbered lines relativenumber = false, -- set relative numbered lines numberwidth = 4, -- set number column width to 2 {default 4} signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time wrap = false, -- display lines as one long line scrolloff = 8, -- is one of my fav sidescrolloff = 8, guifont = "monospace:h17", -- the font used in graphical neovim applications backupdir = "/home/penguin/.vim/backup//", directory = "/home/penguin/.vim/swap//", } for k, v in pairs(options) do vim.opt[k] = v end vim.cmd [[ augroup RestoreCursorShapeOnExit autocmd! autocmd VimSuspend,VimLeave * set guicursor=a:ver50 augroup END]] vim.cmd [[ augroup Markdown autocmd! autocmd FileType markdown setlocal wrap shiftwidth=2 tabstop=2 augroup END ]] vim.cmd [[ augroup Lua autocmd! autocmd FileType lua setlocal shiftwidth=2 tabstop=2 augroup END ]] -- vim.opt.cinoptions:append("=0")