dotfiles/init.lua
Joshua Finch 5e9a7530b5 Changing to packer bootstrap from a function that was called immediately
after being defined into fewer and easier to read procedural lines.
2024-01-30 11:25:38 -06:00

594 lines
25 KiB
Lua

-- ``````````````````````````````````````````````-',~_'--```````````````````````````` ``
-- `````````````````````````````````````````````-,;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()
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 gruvbox = softrequire('gruvbox')
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
local vimset = vim.opt
-- Standard Vim style settings
vimset.background = 'dark' -- Force a dark background for the colorscheme
vimset.clipboard =
"unnamed,unnamedplus" -- Use both the "*" and "+" registers for yanks and deletes (puts things in the system clipboard)
vimset.colorcolumn = '121' -- Highlight column to show
vimset.completeopt = 'menu,menuone,noinsert' -- Change how the completion menu is interacted with
vimset.cursorline = true -- Highlight the line the cursor is on.
vimset.expandtab = true -- Expand tabs into spaces
vimset.fileformat =
'unix' -- Explicitly state that files should use the unix style EOL characters.
vimset.fillchars = 'fold: ' -- Sets the character that fills in a fold line
vimset.foldexpr =
'nvim_treesitter#foldexpr()' -- Uses Treesitter to determine where code folding should occur
vimset.foldlevel = 10 -- Sets the initial level at which folds will be closed
vimset.foldmethod = 'expr' -- Attempt to use the syntax of a file to set folds.
vimset.formatoptions =
'cqrto' -- Allow auto insertion of comment lines when using o or O on a comment.
vimset.list = true -- Show the listchars
vimset.listchars = 'tab:|·,trail:¬,extends:>,precedes:<,nbsp:+' -- Characters to display when showing whitespace
vimset.mouse = 'a' -- Enable mouse mode
vimset.number = true -- Show the line number in the gutter.
vimset.relativenumber = true -- Relative line number
-- vimset.scrolloff = 8 -- Keep a minimum number of lines shown when paging down
vimset.shiftround = true -- Round indentation to shiftwidth
vimset.shiftwidth = 4 -- Number of spaces a tab counts for when converting tabs to spaces
vimset.shortmess = 'at' -- Abbreviations and truncation of cmd messages
vimset.showmatch = true -- Show matching bracket
vimset.signcolumn = 'yes' -- Always show the gutter
vimset.smartindent = true -- Attempt to insert indentation to fit traditional languages.
vimset.softtabstop = 4
vimset.splitbelow = true -- Split windows below when horizontal splitting
vimset.splitright = true -- Split windows right when vertical splitting
vimset.swapfile = false -- Disable the creation of swap files for open files
vimset.tabstop = 4 -- Setting the value of spaces per tab
vimset.termguicolors = true -- Enable the truecolor GUI colors in a terminal
vimset.undodir = os.getenv('HOME') .. '/.config/nvim/undodir' -- Set a specific undo file directory
vimset.undofile = true -- Enable undo files
vimset.updatetime = 50 -- Update time in milliseconds
vimset.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)
keymap('v', '>', '>gv', options)
-- Visual selection can be moved up and down
keymap('v', 'J', ':m \'>+1<CR>gv=gv')
keymap('v', 'K', ':m \'<-2<CR>gv=gv')
-- Sort selected lines alphabetically, descending
keymap('v', '<leader>s', ':sort<CR>', options)
-- Move between panes in Neovim
keymap('n', '<C-j>', '<C-w>j', options)
keymap('n', '<C-k>', '<C-w>k', options)
keymap('n', '<C-h>', '<C-w>h', options)
keymap('n', '<C-l>', '<C-w>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', '<leader>n', ':bn<CR>', options)
keymap('n', '<leader>p', ':bp<CR>', options)
keymap('n', '<leader>d', ':bp|bd #<CR>', options)
-- Reload the nvim config
keymap('n', '<leader><leader>r', ":source % | PackerCompile<CR>", options)
-- Toggle spellcheck
keymap('n', '<leader>s', ':set spell!<CR>', options)
-- Quick exit from Insert mode
keymap('i', 'jk', '<ESC>', options)
-- Toggle display of whitespace chars
keymap('n', '<leader>w', ':set list!<CR>', options)
-- Floating terminal
keymap('n', 't', ':FloatermToggle myfloat<CR>')
keymap('t', '<ESC>', '<C-\\><C-n>:q<CR>')
-- Folding the section under the cursor
keymap('n', '<space>', 'za')
-- Keymaps for custom functions
keymap('n', '<leader>et', function() execute('test') end)
keymap('n', '<leader>er', function() execute('run') end)
keymap('n', '<leader>eb', function() execute('benchmark') end)
-- Vim-Fugitive
keymap('n', '<leader>gis', vim.cmd.Git)
keymap('n', '<leader>gid', vim.cmd.Gdiff)
keymap('n', '<leader>eo', ':Explore<CR>', 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
-- TODO: Determine if this is required
-- 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', '<c-k>', vim.diagnostic.goto_prev, bufopts)
keymap('n', '<c-j>', 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', '<leader>D', vim.lsp.buf.type_definition, bufopts)
keymap('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
keymap('n', 'gr', vim.lsp.buf.references, bufopts)
keymap('n', '<leader><leader>f', function() vim.lsp.buf.format { async = true } end, bufopts)
-- DAP debug
if dap then
keymap('n', '<F5>', function() dap.continue() end, bufopts)
keymap('n', '<F10>', function() dap.step_over() end, bufopts)
keymap('n', '<F11>', function() dap.step_into() end, bufopts)
keymap('n', '<F12>', function() dap.step_out() end, bufopts)
keymap('n', '<leader>b', function() dap.toggle_breakpoint() end, bufopts)
end
end
-- Module loading
if mason and mason_lspconfig and nvim_lsp then
mason.setup {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
}
}
}
mason_lspconfig.setup {
automatic_installation = true,
}
mason_lspconfig.setup_handlers {
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 = {
["<ESC>"] = actions.close
},
},
}
}
keymap('n', '<leader>ff', telescope_builtin.find_files, options)
keymap('n', '<leader>fg', telescope_builtin.git_commits, options)
keymap('n', '<leader>fh', telescope_builtin.help_tags, options)
keymap('n', '<leader>fr', telescope_builtin.live_grep, options)
keymap('n', '<leader>fm', telescope_builtin.marks, options)
keymap('n', '<leader>fb', telescope_builtin.buffers, options)
keymap('n', '<leader>fd', telescope_builtin.diagnostics, options)
end
if treesitter_configs then
treesitter_configs.setup {
auto_install = true,
ensure_installed = { 'typescript', 'javascript', 'vimdoc', 'query', 'c', 'rust', 'comment', 'lua', 'python' },
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 = '<nop>',
},
}
keymap('n', '<leader>c', ':norm gcc<CR>', options)
keymap('v', '<leader>c', ':norm gc<CR>', 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', '<leader>zp', telekasten.panel, options)
keymap('n', '<leader>zn', telekasten.find_notes, options)
keymap('n', '<leader>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
['<c-n>'] = cmp.mapping.select_next_item(),
['<c-p>'] = cmp.mapping.select_prev_item(),
['<c-j>'] = cmp.mapping.scroll_docs(-4),
['<c-k>'] = cmp.mapping.scroll_docs(4),
['<c-space>'] = cmp.mapping.complete(),
['<c-y>'] = 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
if gruvbox then
gruvbox.setup({
contrast = 'hard',
})
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,
}
)