-- ``````````````````````````````````````````````-',~_'--```````````````````````````` `` -- `````````````````````````````````````````````-,;iF^:;:_'`````````````````````````` ` ` -- ``````````````````````````````-`````----````--.-.,~:|>>|*\r;:_,::__,:-``-```````````````` ` -- `````````````````````-------------`----'','~;:,~,:=^^|c{jtv>i|{Pekmxr::^^;:;'```````````` ```` -- `````````````````-``----------`---.''',_;?|\^=?*|;^rv{aKk9j^^fmmXKQOw/iz/\vxFL^:-``````````` ```` -- `````````````````----`---------`--.':^:;^>JZja{k{iav|oKoUvc]*^iHgZ=L]PX9OKFUPomar````````````````````` -- ` ````````````````------------------.',;;LJvyjj$9yr/ohot*:^:^?|veht|cved6DgR9D$amov>>:'````````````````` -- ```````````````------------------.''..',:r^>vyyZkwoL^_;r|t|>|mx1F{ijZfjOR$wj=vK&QNNDUhgNe\_-``````````````` -- ````````````````-----------------',;:;;\veec7oj{v}\L^;;|zfj2aaov|\vc\vKD#Qe7zJlZ$heRgRHHBMe|*;'````````````` -- `````````````````--------------.'_^|xamekKMmL\|lv?>?|;|irr/eh99Oa6OaukN88DU6MS6UXUUMQ8UHQQ#De\.````````````` -- ``````````````````-------------.',_;?zoDHNR9Ko?\xft=r|1/vtivKQNDgM8ROQMNQOoXPKKawh&#Qghut9QQ#ki;;r^;'--`````- -- ````````````-''',,,'--------',:^|/=icfo6eOKS/lculr\/7vyya]me#QQQQQQmKgDBOtf9ESjueyoetoeFyP6#Q#gO9P?,''------- -- `````````-.',,;r|iFvr'-.'_'':rzoe|^r:;vvv?^/ii2E8qvi|vmo6ZDRd#Q8ZKw6KgRR96dRNZZekeeoXRMDwEqePQQQQ8wfi;'...--.. -- `````````-',_;;;L\tjaoo{i\*^||{fPZ?;;::'~;r;||\{KRHeoXZoyuZEOKDODkPewOEdRK9KKKQdhRPRENQQgKSJKeuEQQQ#D9v:'''''''' -- ````````.,_:;;/|\ySa|2XeOZOSEFrrr\>;;;;:^?>7FyZ}mOgNRH&NQQ#DHOw9PUKmmmm6Q@QgOdDNg9HHQRRHgdEZK66wjRNB#NHj*,''''''' -- ```````,;/71/1avjEZ6ZZmHu6MNBe|rrr::;^>\SJ?FP{mS2etUD#Q@@@@@QQ&EHKmSPmOkZNNOZdN8HgDKQHBNKqHoao2mPwkRNDol/,,'''''' -- ````````.;zFmK9o{?vU9KKOQMOD#QR\r>,:::r\}oSZeF6ozaROwhafmKQ@@@@@@QQQgeRSwQQQ@#ZZP9K6&Q@QQQOmF{ofeKDPKmeUPZ\~,,,,,,, -- `````````,?tmZS/:;zo|;|LzceQ8w$av~;r*eFoPK9PPe$hX9DeHa$kHO@@@@@@@@QQ@@@@BQ@B#PjzZyEoKNHNgNQKhmc|t22XOOeai^:~,,,,,,, -- ```````-':^?zu\;c|fvr*xv*\|uJoojv:;|ca9OMgdKKdeZFeuO9dHRQQ9K@@@@@@@@@@@@@QOaoe6NQQQQdQQBQ6PgO$a1|JSjaZv\>;:::_~~~~~ -- `````''_;;*\Fuc^>^i|;iXv|LuJf21{i^?1FmeqKD##NNOQRE2fjKDKPSqNQ@@@@Q@@@QQQQQmuw9g#NBQNNNNNXP#RoZDKqke9m{|;:::::::____ -- ```-,;\/=*7FjF\^|c^vL|1Ju||$R#kvi\i1a9O6PoD69Ua9KkFoXDqa2NMQ@@@@@#D&PRBQQDeLzf/^zMMHODNHgP9EOQBNQQQBMSv>;:::::::::_ -- ``-~=Lcuvum6\\c>irrF2]emeaueQQQ9OKPP9K2EK2j/xjoa\lt1yZy6mXfNQgOBO1FHBQQQQQ@Ny/;]j?\Fo9DR8gB&gNN##QQQgo1*:::::::___~ -- ``,?1ouayvjr>c|>rJPMDKKeU&69DQQ#KKfwwutjDkoySSu:;:;r||z}aKS8NNR&BDN#QQQ&#Bdtg@QhEjZj6m6DHNN&OPah$UKKOPf*::::::_~~,, -- `-:\SomOU/:^\\ou7FdHdgQ8#OXo6QQdooJ}>:,:Kqcv\;^=c*r;;^;icv}Q#NRDHjPS\/vvc]tmkK@QNq6fjox6MR$6E2oZeaOdNgX|;::::_~~,,, -- `';\ceKODe1vFyhmSZUO6KjFKuSSx9HMPvvtz;,=O>,,,,~~__::::::*|1JhQQ#Ng]i:..,;;;:;^r;rv2fcyPoxvauS]jooX9RMRSe2vr^;_,,,,, -- `.,;LF/av^^c9OUNge>\JFege/\}>:iuZB9\\7E#},,,~~~_::::::::::::;mQQN{ZQu::::::::::::::;^;**\\^|vvveOaP&dkOmyKHOec;,,,, -- `_>lzv\fZutyKomhFevi7vlkcrru>c}FUQQDUKodh:~_~__:::::;;:;zdPm9kjziiKQNowc_~~~_____~?:~:;^|rr\uyo686wR&RKaaHRUPP/:,,' -- `,r\\/jkK6q8Hjr^|Jj\z1zJPeo6wawZ$${jeOO8RowJr;;rvxL|vvoOgOt*^|c}K#QDmemwv*:,,,,,,_r,,_^r\v2yZju$#QNQOXmS2PNRUPj^''' -- `-,:,_,::;xotli;;^r*\aPm]l{jv;:,,,,''?f6Ujj{tuKK9DNgOjc/Pquuj7?|L\^::::>v]Fi{i:,,;__:r|\>1ahweZOgNgEooOKkoRDqhu|;'' -- ``````````-~r''r^,_;r?r/?^?;::_,,,,,'-',::::^/\ueDNPL>/9g/;::::::::::::_:::~_;r^^/=^^=\\77wjwmmPD6mm6KRw}o9ROKP6z_' -- ```````````-,;^;r?;:,'''~,''',,,,,,,,,''.',,~:vx\mO?;z\::::::::::::::::_~,,,,;|:={|>7;^||L?\v/1cvf2eo{}zv}6Rd9KD9i~ -- ```````````--','''''''''''',,,,,,,,~~~~~~'''',;\w96?;v^::::::::::::::::_~,,,,,'';^',^;;7ir:;?;^*;xeea96Z1FumUt;,:;, -- ````````````----.'''''''''',,,,,~~~~~~___~~:::;/URUc;rF|::::::::::::::_~,,,,,,,''''',;;;'~|{1*^rc{Z2eoxaZoee?,''''' -- `````````````----''''''''''',,,,~~~~~~~~~~,~~_::^L/~Fc^?z/;:::::::::~~,,,,,,,,,,''''''''''',:''''',rr*>/ti\^:''''.' -- ```````````------.''',,,,,,,,,,,~~~~~,,,,,,,,,,~__:,^xl>_;z/;:::::::,,,,,,,,,,,'''''''''''''''...'.'''''',,,''''''' -- `````````--------'''',,,,,,,,,,,,,~~,~~~~,,,,~~,,,,_~_:r?__v/:::::~,,,,,,,'''''''''''''''''''''..'''''''''''''''''' -- ```````````------''''''''',,,,,,,,,~~~~_~~~,,,~,,,,,,,':rr;;1;::_~,,,,,,'',,'''''''''''''''''''..'''''''''''''''''' -- ````````````-----''''',''',,,,,,,,,,,,~~,,,,,,,,,,,,_~'';==;}^~,,,,,,,,,'''''''''''''''''''......'''''''''''''''''' -- ```````---------.'''',,,,,,,,,,,,,,,,,,,,,,,,,,,~;^\\Jv\yweomEe2}\^;:,,,,,,,'''''''''''.......----.'''''''''''''''' -- `````-----``----'''''',,,,,,,,,,,,,,,,,,,,,,_:rc1ioP$ODh{Fj#gHBg#QQ#Kj/1?;;,,''''''''''.----------..''''''''''''''' -- `````-----```---''''''',,,,,,,,,,,,~:_::;^>\Jt1SZmwPavoOahONONB#QQBgd8Rk&PXjFvc?;~_,''''.------`---...-.''''''''''' -- -- Created: 7/2/2012 -- Custom Functions -- 'softrequire' provides a wrapper around the builtin require. If the require has failed in a `local mod = softrequire('m') call, a quick check of -- 'if mod then' can wrap code dependent upon the require, and fails gracefully local function softrequire(m) local ok, err = pcall(require, m) if not ok then return nil, err end return err end local function execute(type) local command_table = { run = { java = "java %", python = "python %", rust = "cargo run", }, test = { python = "python test", rust = "cargo test", }, benchmark = { rust = "cargo bench", }, } vim.api.nvim_command('write') local command = command_table[type][vim.bo.filetype] if command ~= nil then vim.cmd('FloatermNew --autoclose=0 ' .. command) end end -- Force install Packer if it is not found locally local packer_need_bootstrap = false local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' if vim.fn.empty(vim.fn.glob(install_path)) > 0 then vim.fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }) vim.cmd [[packadd packer.nvim]] packer_need_bootstrap = true end -- Manage plugins require('packer').startup(function(use) use 'wbthomason/packer.nvim' -- Packer self management -- Completion, linting, search use 'neovim/nvim-lspconfig' -- Adds native support for language servers and autocompletion use { 'williamboman/mason.nvim', -- Installer for LSPs, DAP, linters, etc run = ':MasonUpdate', } use 'williamboman/mason-lspconfig.nvim' -- Bridges the gap between lspconfig and mason use { 'nvim-telescope/telescope.nvim', -- Popup, quick search plugin for looking up files, files content, loading a filebrowser, etc requires = { { 'nvim-lua/plenary.nvim' } } } use { 'nvim-treesitter/nvim-treesitter', -- Support for syntax highlighting (and other bits) run = ':TSUpdate' } use 'tpope/vim-surround' -- Change surrounding characters '{},[],quotes,etc' use 'numToStr/Comment.nvim' -- Fancy commenting plugin -- Completion support use 'hrsh7th/cmp-nvim-lsp' -- Completion source for nvim-cmp: LSPs use 'hrsh7th/cmp-buffer' -- Completion source for nvim-cmp: buffer use 'hrsh7th/cmp-path' -- Completion source for nvim-cmp: path use 'hrsh7th/cmp-cmdline' -- Completion source for nvim-cmp: vim's cmdline use 'hrsh7th/nvim-cmp' -- Completion engine for neovim -- Snippets use 'L3MON4D3/LuaSnip' -- Snippet engine written in Lua! use 'saadparwaiz1/cmp_luasnip' -- Necessary plugin to load luasnips into nvim-cmp use 'rafamadriz/friendly-snippets' -- Snippets! -- Theming use { 'ellisonleao/gruvbox.nvim', -- Color Scheme config = function() require('gruvbox').setup({ contrast = 'hard', }) vim.cmd('colorscheme gruvbox') end } use { 'nvim-lualine/lualine.nvim', -- Very quick and useful statusline setup requires = { { 'kyazdani42/nvim-web-devicons', opt = true } }, } -- Git use 'airblade/vim-gitgutter' -- Show git diffs in the symbol gutter use 'tpope/vim-fugitive' -- Git integration -- Utility use 'voldikss/vim-floaterm' -- Floating terminal enabling working in the cli without adjusting window layout use 'renerocksai/telekasten.nvim' -- Note taking helper with daily/weekly notes -- Experimental use { 'habamax/vim-godot', ft = { 'gdscript' } } use 'mfussenegger/nvim-dap' use 'rcarriga/nvim-dap-ui' -- Automatically set up your configuration after cloning packer.nvim if packer_need_bootstrap then require('packer').sync() end end) -- Load plugin modules with a softfail option local cmp = softrequire('cmp') local comment = softrequire('Comment') local dap = softrequire('dap') local lualine = softrequire('lualine') local luasnip = softrequire('luasnip') local mason = softrequire('mason') local mason_lspconfig = softrequire('mason-lspconfig') local nvim_lsp = softrequire('lspconfig') local telekasten = softrequire('telekasten') local telescope = softrequire('telescope') local telescope_builtin = softrequire('telescope.builtin') local treesitter_configs = softrequire('nvim-treesitter.configs') -- NEOVIM SETTINGS vim.opt.background = 'dark' -- Force a dark background for the colorscheme vim.opt.clipboard = "unnamed,unnamedplus" -- Use both the "*" and "+" registers for yanks and deletes (puts things in the system clipboard) vim.opt.colorcolumn = '121' -- Highlight column to show vim.opt.completeopt = 'menu,menuone,noselect' -- Change how the completion menu is interacted with vim.opt.cursorline = true -- Highlight the line the cursor is on. vim.opt.expandtab = true -- Expand tabs into spaces vim.opt.fileformat = 'unix' -- Explicitly state that files should use the unix style EOL characters. vim.opt.fillchars = 'fold: ' -- Sets the character that fills in a fold line vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' -- Uses Treesitter to determine where code folding should occur vim.opt.foldlevel = 10 -- Sets the initial level at which folds will be closed vim.opt.foldmethod = 'expr' -- Attempt to use the syntax of a file to set folds. vim.opt.formatoptions = 'cqrto' -- Allow auto insertion of comment lines when using o or O on a comment. vim.opt.list = true -- Show the listchars vim.opt.listchars = 'tab:|·,trail:¬,extends:>,precedes:<,nbsp:+' -- Characters to display when showing whitespace vim.opt.mouse = 'a' -- Enable mouse mode vim.opt.number = true -- Show the line number in the gutter. vim.opt.relativenumber = true -- Relative line number vim.opt.shiftround = true -- Round indentation to shiftwidth vim.opt.shiftwidth = 4 -- Number of spaces a tab counts for when converting tabs to spaces vim.opt.shortmess = 'at' -- Abbreviations and truncation of cmd messages vim.opt.showmatch = true -- Show matching bracket vim.opt.signcolumn = 'yes' -- Always show the gutter vim.opt.smartindent = true -- Attempt to insert indentation to fit traditional languages. vim.opt.softtabstop = 4 -- Number of spaces a tab counts for when converting tabs to spaces vim.opt.splitbelow = true -- Split windows below when horizontal splitting vim.opt.splitright = true -- Split windows right when vertical splitting vim.opt.swapfile = false -- Disable the creation of swap files for open files vim.opt.tabstop = 4 -- Setting the value of spaces per tab vim.opt.termguicolors = true -- Enable the truecolor GUI colors in a terminal vim.opt.undodir = os.getenv('HOME') .. '/.config/nvim/undodir' -- Set a specific undo file directory vim.opt.undofile = true -- Enable undo files vim.opt.updatetime = 50 -- Update time in milliseconds vim.opt.wrap = false -- Do _not_ wrap lines -- KEYBOARD SHORTCUTS vim.g.mapleader = ',' local keymap = vim.keymap.set -- Standard keybinding options local options = { noremap = true } -- Block tab/untab without leaving visual mode keymap('v', '<', '', '>gv', options) -- Visual selection can be moved up and down keymap('v', 'J', ':m \'>+1gv=gv') keymap('v', 'K', ':m \'<-2gv=gv') -- Sort selected lines alphabetically, descending keymap('v', 's', ':sort', options) -- Move between panes in Neovim keymap('n', '', 'j', options) keymap('n', '', 'k', options) keymap('n', '', 'h', options) keymap('n', '', 'l', options) -- Don't move the cursor when appending the following line to the current keymap('n', 'J', 'mzJ`z') -- Switch or close buffers in the window keymap('n', 'n', ':bn', options) keymap('n', 'p', ':bp', options) keymap('n', 'd', ':bp|bd #', options) -- Reload the nvim config keymap('n', 'r', ":source % | PackerCompile", options) -- Toggle spellcheck keymap('n', 's', ':set spell!', options) -- Quick exit from Insert mode keymap('i', 'jk', '', options) -- Toggle display of whitespace chars keymap('n', 'w', ':set list!', options) -- Floating terminal keymap('n', 't', ':FloatermToggle myfloat') keymap('t', '', ':q') -- Folding the section under the cursor keymap('n', '', 'za') -- Keymaps for custom functions keymap('n', 'et', function() execute('test') end) keymap('n', 'er', function() execute('run') end) keymap('n', 'eb', function() execute('benchmark') end) -- Vim-Fugitive keymap('n', 'gis', vim.cmd.Git) keymap('n', 'gid', vim.cmd.Gdiff) keymap('n', 'eo', ':Lexplore', options) -- Auto-recompile and load on init.lua file changes vim.api.nvim_create_autocmd({ 'BufWritePost' }, { pattern = { 'init.lua' }, group = vim.api.nvim_create_augroup('nvim_reload', { clear = true }), command = "source % | PackerCompile" }) -- Fix for treesitter folds, as folds are not recalculated upon buffer changes (especially when pasting text) vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNew', 'BufWinEnter' }, { pattern = '*', group = vim.api.nvim_create_augroup('telescope_fold_workaround', { clear = true }), command = 'set foldexpr=nvim_treesitter#foldexpr()', }) -- Create a new copy of capabilities and enable the snippetSupport local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true if luasnip then require('luasnip.loaders.from_vscode').lazy_load() -- Attempt to load VSCode based snippets end -- All functions and keymappings contained here are universal to LSPs local on_attach = function(client, bufnr) vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') -- Keyboard Mappings local bufopts = { noremap = true, silent = true, buffer = bufnr } keymap('n', '', vim.diagnostic.goto_prev, bufopts) keymap('n', '', vim.diagnostic.goto_next, bufopts) -- keymap('n', 'gl', vim.diagnostic.open_float, bufopts) keymap('n', 'ga', vim.lsp.buf.code_action, bufopts) keymap('n', 'gD', vim.lsp.buf.declaration, bufopts) keymap('n', 'gd', vim.lsp.buf.definition, bufopts) keymap('n', 'K', vim.lsp.buf.hover, bufopts) keymap('n', 'gi', vim.lsp.buf.implementation, bufopts) keymap('n', 'gs', vim.lsp.buf.signature_help, bufopts) keymap('n', 'D', vim.lsp.buf.type_definition, bufopts) keymap('n', 'rn', vim.lsp.buf.rename, bufopts) keymap('n', 'gr', vim.lsp.buf.references, bufopts) keymap('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) -- DAP debug if dap then keymap('n', '', function() dap.continue() end, bufopts) keymap('n', '', function() dap.step_over() end, bufopts) keymap('n', '', function() dap.step_into() end, bufopts) keymap('n', '', function() dap.step_out() end, bufopts) keymap('n', 'b', function() dap.toggle_breakpoint() end, bufopts) end end -- Module loading if mason and mason_lspconfig and nvim_lsp then mason.setup {} mason_lspconfig.setup { automatic_installation = true, } mason_lspconfig.setup_handlers { -- Default LSP handler function(server_name) nvim_lsp[server_name].setup { capabilities = capabilities, on_attach = on_attach } end, ['rust_analyzer'] = function() nvim_lsp.rust_analyzer.setup { capabilities = capabilities, on_attach = on_attach, settings = { ['rust-analyzer'] = { checkOnSave = true, check = { command = 'clippy', extraArgs = { '--', '-Dclippy::all', '-Wclippy::pedantic' }, }, diagnostics = { enable = true, experimental = { enable = true, } } } } } end, ['lua_ls'] = function() nvim_lsp.lua_ls.setup { capabilities = capabilities, on_attach = on_attach, settings = { Lua = { diagnostics = { globals = { 'vim' } } } } } end, } -- Manually adding gdscript as Mason doesn't handle this anymore -- nvim_lsp.gdscript.setup {} end if telescope and telescope_builtin then local actions = require('telescope.actions') telescope.setup { defaults = { file_ignore_patterns = { '.png$', '.jpg$', '.jpeg$', '.ico$', '.icns$', '.webp$', '.uproject$', -- Unreal Engine '-workspace$', }, results_title = false, prompt_prefix = '  ', selection_caret = '➤ ', mappings = { i = { [""] = actions.close }, }, } } keymap('n', 'ff', telescope_builtin.find_files, options) keymap('n', 'fg', telescope_builtin.git_commits, options) keymap('n', 'fh', telescope_builtin.help_tags, options) keymap('n', 'fr', telescope_builtin.live_grep, options) keymap('n', 'fm', telescope_builtin.marks, options) keymap('n', 'fb', telescope_builtin.buffers, options) keymap('n', 'fd', telescope_builtin.diagnostics, options) end if treesitter_configs then treesitter_configs.setup { auto_install = true, ensure_installed = { 'c', 'c_sharp', 'comment', 'css', 'html', 'java', 'javascript', 'json', 'lua', 'python', 'query', 'rust', 'toml', 'tsx', 'typescript', 'vimdoc', 'yaml', }, highlight = { enable = true, additional_vim_regex_highlighting = false, }, incremental_selection = { enable = true, }, indent = { enable = true, }, rainbow = { enable = true, } } end if comment then comment.setup { ignore = '^$', toggler = { line = 'gc', block = '', }, } keymap('n', 'c', ':norm gcc', options) keymap('v', 'c', ':norm gc', options) end if lualine then lualine.setup { -- See :h lualine-Default-Configuration for defaults and options tabline = { -- Set the contents of the top left tabline lualine_a = { 'tabs', }, lualine_z = { 'buffers', } } } end if telekasten then local home = vim.fn.expand('~/.zettelkasten') telekasten.setup({ home = home, dailies = home .. '/' .. 'daily', weeklies = home .. '/' .. 'weeklies', templates = home .. '/' .. 'templates', template_new_note = home .. '/' .. 'templates/new_note.md', template_new_daily = home .. '/' .. 'templates/daily.md', template_new_weekly = home .. '/' .. 'templates/weekly.md', command_palette_theme = 'ivy', show_tags_theme = 'get_cursor', plug_into_calendar = false, }) -- Color for telekasten syntax vim.api.nvim_set_hl(0, 'tkLink', { ctermfg = 72, cterm = { bold = true, underdouble = true }, fg = '#689d6a', bold = true, underdouble = true }) vim.api.nvim_set_hl(0, 'tkBrackets', { ctermfg = 'gray', fg = 'gray' }) vim.api.nvim_set_hl(0, 'tkTag', { ctermfg = 'gray', fg = 'gray' }) keymap('n', 'zp', telekasten.panel, options) keymap('n', 'zn', telekasten.find_notes, options) keymap('n', 'zt', telekasten.show_tags, options) end -- nvim-cmp config if cmp then cmp.setup { snippet = { -- REQUIRED, the plugin will NOT work without a snippet engine enabled expand = function(args) -- Enable luasnips if luasnip then luasnip.lsp_expand(args.body) end end }, completion = { completeopt = 'menu,menuone,noinsert' -- TODO: Necessary copy of the default completeopt? }, experimental = { ghost_text = true, }, mapping = { -- Key mappings based off of the standard autocomplete keybindings from VIM [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true, }), }, formatting = { format = function(entry, vim_item) -- vim_item.kind = string.format('%s', vim_item.kind) vim_item.menu = ({ buffer = '[Buf]', nvim_lsp = '[LSP]', luasnip = '[Snips]', nvim_lua = '[Lua]' })[entry.source.name] return vim_item end, fields = { 'abbr', 'kind', 'menu' } }, sources = { -- NOTE: the order of sources determines their loading priority in the autocomplete menu { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, { name = 'buffer', keyword_length = 2 }, }, } -- Enable the ':' character for the vim commandline completion, eg. for nvim commands cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'path' }, { name = 'cmdline', keyword_length = 2 } } }) -- Enable the '/' and '?' character for the completion of in buffer elements only to autocomplete the search command cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } } }) end vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { underline = true, virtual_text = true, signs = true, update_in_insert = true, } )