diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-02-10 11:19:21 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-02-10 11:19:21 +0200 |
| commit | b91ee8da3ef2c1c154833b4b6e99250fe2c280e7 (patch) | |
| tree | 56bc9d8b84e959105ee6c7e3ac6c9ab97bd71bbe /.config/nvim/lua/user | |
| parent | d90ccf4d620eb6da75f1dbf8aa98aa85aa799ffe (diff) | |
| download | dotfiles-b91ee8da3ef2c1c154833b4b6e99250fe2c280e7.tar.gz dotfiles-b91ee8da3ef2c1c154833b4b6e99250fe2c280e7.zip | |
Removed all nvim files
Diffstat (limited to '.config/nvim/lua/user')
| -rw-r--r-- | .config/nvim/lua/user/keys.lua | 380 | ||||
| -rw-r--r-- | .config/nvim/lua/user/mods.lua | 138 | ||||
| -rw-r--r-- | .config/nvim/lua/user/opts.lua | 250 | ||||
| -rw-r--r-- | .config/nvim/lua/user/pack.lua | 421 | ||||
| -rw-r--r-- | .config/nvim/lua/user/utils.lua | 85 |
5 files changed, 0 insertions, 1274 deletions
diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua deleted file mode 100644 index 8feee85..0000000 --- a/.config/nvim/lua/user/keys.lua +++ /dev/null @@ -1,380 +0,0 @@ ---[[ key.lua ]] - - -------------- Shorten Function Names -------------- -local keymap = vim.keymap -local map = function(mode, l, r, opts) - opts = opts or {} - opts.silent = true - opts.noremap = true - keymap.set(mode, l, r, opts) -end -local term_opts = { noremap = true, silent = false } - - ---------------- Standard Operations --------------- --- Semi-colon as leader key -vim.g.mapleader = ";" - --- Jump to next match on line using `.` instead of `;` NOTE: commented out in favour of "ggandor/flit.nvim" ---map("n", ".", ";") - --- Repeat last command using `<Space>` instead of `.` NOTE: commented out in favour of "ggandor/flit.nvim" ---map("n", "<Space>", ".") - --- "jj" to exit insert-mode -map("i", "jj", "<esc>") - --- Reload nvim config -map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>") - - ---------------- Extended Operations --------------- --- Combine buffers list with buffer name -map("n", "<Leader>b", ":buffers<CR>:buffer<Space>") - --- Buffer confirmation -map("n", "<leader>y", ":BufferPick<CR>") - --- Map buffer next, prev and delete to <leader>+(n/p/d) respectively -map("n", "<leader>n", ":bn<cr>") -map("n", "<leader>p", ":bp<cr>") -map("n", "<leader>d", ":bd<cr>") - --- List marks -map("n", "<Leader>m", ":marks<CR>") - --- Toggle set number -map("n", "<leader>$", ":NumbersToggle<CR>") -map("n", "<leader>%", ":NumbersOnOff<CR>") - --- Easier split navigations, just ctrl-j instead of ctrl-w then j ---map("n", "<C-J>", "<C-W><C-J>") ---map("n", "<C-K>", "<C-W><C-K>") ---map("n", "<C-L>", "<C-W><C-L>") ---map("n", "<C-H>", "<C-W><C-H>") - --- Split window -map("n", "<leader>h", ":split<CR>") -map("n", "<leader>v", ":vsplit<CR>") -map("n", "<leader>c", "<C-w>c") - --- Resize Panes -map("n", "<Leader>+", ":resize +5<CR>") -map("n", "<Leader>-", ":resize -5<CR>") -map("n", "<Leader><", ":vertical resize +5<CR>") -map("n", "<Leader>>", ":vertical resize -5<CR>") -map("n", "<Leader>=", "<C-w>=") - --- Map Alt+(h/j/k/l) in insert mode to move directional -map("i", "<A-h>", "<left>") -map("i", "<A-j>", "<down>") -map("i", "<A-k>", "<up>") -map("i", "<A-l>", "<right>") - --- Map Alt+(h/j/k/l) in command mode to move directional -map("c", "<A-h>", "<left>") -map("c", "<A-j>", "<down>") -map("c", "<A-k>", "<up>") -map("c", "<A-l>", "<right>") - --- Map Alt+(h/j/k/l) in selection mode to move directional -map("s", "<A-h>", "<left>") -map("s", "<A-j>", "<down>") -map("s", "<A-k>", "<up>") -map("s", "<A-l>", "<right>") - --- Create tab, edit and move between them -map("n", "<C-T>n", ":tabnew<CR>") -map("n", "<C-T>e", ":tabedit") -map("n", "<leader>[", ":tabprev<CR>") -map("n", "<leader>]", ":tabnext<CR>") - --- "Zoom" a split window into a tab and/or close it ---map("n", "<Leader>,", ":tabnew %<CR>") ---map("n", "<Leader>.", ":tabclose<CR>") - --- Vim TABs -map("n", "<leader>1", "1gt<CR>") -map("n", "<leader>2", "2gt<CR>") -map("n", "<leader>3", "3gt<CR>") -map("n", "<leader>4", "4gt<CR>") -map("n", "<leader>5", "5gt<CR>") -map("n", "<leader>6", "6gt<CR>") -map("n", "<leader>7", "7gt<CR>") -map("n", "<leader>8", "8gt<CR>") -map("n", "<leader>9", "9gt<CR>") -map("n", "<leader>0", "10gt<CR>") - --- Move to the next and previous item in the quickfixlist ---map("n", "]c", "<Cmd>cnext<CR>") ---map("n", "[c", "<Cmd>cprevious<CR>") - --- Hitting ESC when inside a terminal to get into normal mode ---map("t", "<Esc>", [[<C-\><C-N>]]) - --- Move block (indentation) easily -map("n", "<", "<<", term_opts) -map("n", ">", ">>", term_opts) -map("x", "<", "<gv", term_opts) -map("x", ">", ">gv", term_opts) - --- Set alt+(j/k) to switch lines of texts or simply move them -map("n", "<A-k>", ':let save_a=@a<Cr><Up>"add"ap<Up>:let @a=save_a<Cr>') -map("n", "<A-j>", ':let save_a=@a<Cr>"add"ap:let @a=save_a<Cr>') - --- Search and replace -map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c') - --- Map delete to Ctrl+l -map("i", "<C-l>", "<Del>") - --- Clear screen -map("n", "<leader><C-l>", "<Cmd>!clear<CR>") - --- Change file to an executable -map("n", "<leader>x", ":!chmod +x %<CR>") - --- Paste without replace clipboard -map("v", "p", '"_dP') - --- Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in --- visual mode to select text to swap with -map("v", "<C-X>", "<Esc>`.``gvP``P") - --- Clear messages or just refresh/redraw the screen -map("n", "<leader>u", ":echo '' | redraw<CR>") - --- Change Working Directory to current project -map("n", "<leader>cd", ":cd %:p:h<CR>:pwd<CR>") - --- Open the current file in the default program (on Mac this should just be just `open`) -map('n', '<leader>o', ':!xdg-open %<cr><cr>') - --- Unsets the 'last search pattern' register by hitting return ---map("n", "<CR>", "!silent :noh<CR><CR>") - --- Toggle completion -map("n", "<Leader>tc", ":lua require('user.utils').toggle_completion()<CR>") - --- Disable default completion. -map('i', '<C-n>', '<Nop>') -map('i', '<C-p>', '<Nop>') - --- Set line wrap -map("n", "<M-z>", function() - local wrap_status = vim.api.nvim_exec("set wrap ?", true) - - if wrap_status == "nowrap" then - vim.api.nvim_command("set wrap linebreak") - print("Wrap enabled") - else - vim.api.nvim_command("set wrap nowrap") - print("Wrap disabled") - end -end, { silent = true }) - --- Toggle between folds ---utils.map("n", "<F2>", "&foldlevel ? 'zM' : 'zR'", { expr = true }) - --- Use space to toggle fold ---utils.map("n", "<Space>", "za") - --- Make a copy of current file -vim.cmd([[ - map <leader>s :up \| saveas! %:p:r-<C-R>=strftime("%y.%m.%d-%H:%M")<CR>-bak.<C-R>=expand("%:e")<CR> \| 3sleep \| e #<CR> -]]) - --- Toggle transparency -vim.cmd([[ - let t:is_transparent = 0 - function! Toggle_transparent_background() - if t:is_transparent == 0 - hi Normal guibg=#111111 ctermbg=black - let t:is_transparent = 1 - else - hi Normal guibg=NONE ctermbg=NONE - let t:is_transparent = 0 - endif - endfunction - nnoremap <leader>tb :call Toggle_transparent_background()<CR> -]]) ---keymap('n', '<leader>tb', ':Toggle_transparent_background<CR>') - --- Toggle zoom -vim.cmd([[ - function! s:ZoomToggle() abort - if exists('t:zoomed') && t:zoomed - execute t:zoom_winrestcmd - let t:zoomed = 0 - else - let t:zoom_winrestcmd = winrestcmd() - resize - vertical resize - let t:zoomed = 1 - endif - endfunction - command! ZoomToggle call s:ZoomToggle() - ]]) -map("n", "<leader>z", ":ZoomToggle<CR>") - --- Toggle statusline -vim.cmd([[ -let s:hidden_all = 0 -function! ToggleHiddenAll() - if s:hidden_all == 0 - let s:hidden_all = 1 - set noshowmode - set noruler - set laststatus=0 - set noshowcmd - else - let s:hidden_all = 0 - set showmode - set ruler - set laststatus=2 - set showcmd - endif -endfunction -nnoremap <S-h> :call ToggleHiddenAll()<CR> -]]) - --- Open last closed buffer -vim.cmd([[ - function! OpenLastClosed() - let last_buf = bufname('#') - if empty(last_buf) - echo "No recently closed buffer found" - return - endif - let result = input("Open ". last_buf . " in (n)ormal (v)split, (t)ab or (s)plit ? (n/v/t/s) : ") - if empty(result) || (result !=# 'v' && result !=# 't' && result !=# 's' && result !=# 'n') - return - endif - if result ==# 't' - execute 'tabnew' - elseif result ==# 'v' - execute "vsplit" - elseif result ==# 's' - execute "split" - endif - execute 'b ' . last_buf - endfunction - ]]) -map("n", "<C-t>", ":call OpenLastClosed() <CR>") - - ----------------- Plugin Operations ---------------- --- Packer -map("n", "<leader>Pc", "<cmd>PackerCompile<cr>") -map("n", "<leader>Pi", "<cmd>PackerInstall<cr>") -map("n", "<leader>Ps", "<cmd>PackerSync<cr>") -map("n", "<leader>PS", "<cmd>PackerStatus<cr>") -map("n", "<leader>Pu", "<cmd>PackerUpdate<cr>") - --- Tmux navigation (aserowy/tmux.nvim) -map('n', '<C-h>', '<CMD>NavigatorLeft<CR>') -map('n', '<C-l>', '<CMD>NavigatorRight<CR>') -map('n', '<C-k>', '<CMD>NavigatorUp<CR>') -map('n', '<C-j>', '<CMD>NavigatorDown<CR>') - --- ToggleTerm ---map("n", "<leader>tt", "<cmd>ToggleTerm<cr>") - --- LazyGit -map("n", "<leader>gg", ":LazyGit<CR>") - --- Fugitive git bindings -map("n", "<leader>ga", ":Git add %:p<CR><CR>") ---map("n", "<leader>gs", ":Gstatus<CR>") -map("n", "<leader>gc", ":Gcommit -v -q<CR>") -map("n", "<leader>gt", ":Gcommit -v -q %:p<CR>") ---map("n", "<leader>gd", ":Gdiff<CR>") -map("n", "<leader>ge", ":Gedit<CR>") ---map("n", "<leader>gr", ":Gread<Cj>") -map("n", "<leader>gw", ":Gwrite<CR><CR>") -map("n", "<leader>gl", ":silent! Glog<CR>:bot copen<CR>") ---map("n", "<leader>gp", ":Ggrep<Space>") ---map("n", "<Leader>gp", ":Git push<CR>") ---map("n", "<Leader>gb", ":Gblame<CR>") -map("n", "<leader>gm", ":Gmove<Space>") ---map("n", "<leader>gb", ":Git branch<Space>") ---map("n", "<leader>go", ":Git checkout<Space>") ---map("n", "<leader>gps", ":Dispatch! git push<CR>") ---map("n", "<leader>gpl", ":Dispatch! git pull<CR>") --- map["<C-\\>"] = { "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" } --- map["<leader>gg"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } --- map["<leader>tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" } --- map["<leader>tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" } --- map["<leader>tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" } --- map["<leader>tp"] = { function() toggle_term_cmd "python" end, desc = "ToggleTerm python" } --- map["<leader>tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } --- map["<leader>tf"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "ToggleTerm float" } --- map["<leader>th"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "ToggleTerm horizontal split" } --- map["<leader>tv"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "ToggleTerm vertical split" } ---end - --- Telescope -map("n", "<leader>ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end) -- find all files -map("n", "<leader>fF", "<cmd>lua require('telescope.builtin').find_files()<cr>") -- find files with hidden option -map("n", "<leader>fb", "<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<cr>") -map("n", "<leader>fc", "<cmd>lua require('telescope.builtin').commands()<cr>") -map("n", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>") -map("n", "<leader>fp", "<cmd>Telescope pickers<cr>") -map("n", "<leader>fr", "<cmd>lua require('telescope.builtin').registers({})<CR>") -- registers picker -map("n", "<leader>cf", "<cmd>Telescope changed_files<cr>") -map("n", "<leader>fd", "<cmd>lua require('telescope.builtin').diagnostics()<cr>") -map("n", "<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>") -map("n", "<leader>fk", "<cmd>lua require('telescope.builtin').keymaps()<cr>") -map("n", "<leader>fn", [[<Cmd>lua require'plugins.telescope'.find_notes()<CR>]]) -- find notes -map("n", "<leader>fgn", [[<Cmd>lua require'plugins.telescope'.grep_notes()<CR>]]) -- search notes -map("n", "<leader>f.", [[<Cmd>lua require'plugins.telescope'.find_configs()<CR>]]) -- find configs -map("n", "<leader>fm", "<cmd>lua require('telescope').extensions.media_files.media_files({})<cr>") -- find media files - --- FZF -map("n", "<leader>fz", "<cmd>lua require('fzf-lua').files()<CR>") - --- Nvim-tree -map("n", "<leader>f", ":NvimTreeToggle<CR>", {}) - --- Markdown-preview -map("n", "<leader>md", "<Plug>MarkdownPreviewToggle") - --- Autopairs -Toggle_autopairs = function() - local ok, autopairs = pcall(require, "nvim-autopairs") - if ok then - if autopairs.state.disabled then - autopairs.enable() - print("autopairs on") - else - autopairs.disable() - print("autopairs off") - end - else - print("autopairs not available") - end -end -map("n", "<leader>ww", ":lua Toggle_autopairs()<CR>", term_opts) - --- Tabularize ---vim.cmd([[ --- vnoremap <expr> <Leader>mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "<CR>" --- nnoremap <expr> <Leader>mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "<CR>" --- "nnoremap <leader>i mc40A <esc>080lDgelD`cP --- "vnoremap <leader>ii mc0f-20i<Space><Esc>`cdt=j ---]]) - --- EasyAlign ---vim.cmd([[ --- " Start interactive EasyAlign in visual mode (e.g. vipga) --- xmap ga <Plug>(EasyAlign) --- " Start interactive EasyAlign for a motion/text object (e.g. gaip) --- nmap ga <Plug>(EasyAlign) --- if !exists('g:easy_align_delimiters') --- let g:easy_align_delimiters = {} --- endif --- let g:easy_align_delimiters['--'] = { 'pattern': '--', 'ignore_groups': ['String'] } --- nnoremap <F1> 21A <Esc>d21\| --- imap <F1> <Esc><F1>a ---]]) diff --git a/.config/nvim/lua/user/mods.lua b/.config/nvim/lua/user/mods.lua deleted file mode 100644 index ec77173..0000000 --- a/.config/nvim/lua/user/mods.lua +++ /dev/null @@ -1,138 +0,0 @@ ---vim.cmd([[ --- function RandomColorScheme() --- let mycolors = split(globpath(&rtp,"**/colors/*.vim"),"\n") --- exe 'so ' . mycolors[localtime() % len(mycolors)] --- unlet mycolors --- endfunction --- --- call RandomColorScheme() --- --- :command NewColor call RandomColorScheme() ---]]) - ---vim.cmd([[ --- function RandomColorSchemeMyPicks() --- let mypicks = ["pyte", "fokus", "github", "peachpuff", "morning", "simple256", "xcode", "gruvbox"] --- let mypick = mypicks[localtime() % len(mypicks)] --- echom mypick --- execute 'colo' mypick --- endfunction --- --- command NewColor call RandomColorSchemeMyPicks() --- --- let s:use_gui = exists('g:neovide') || has('gui_running') || (has('termguicolors') && &termguicolors) --- if (s:use_gui) --- call RandomColorSchemeMyPicks() --- endif ---]]) - -vim.cmd([[ - let g:fzf_history_dir = '~/.local/share/fzf-history' - map <leader>z :FZF<CR> - map <leader>a :Files<CR> - map <leader>l :Lines<CR> - map <leader>L :BLines<CR> - map <leader>B :Buffers<CR> - map <leader>h :History:<CR> - nnoremap <leader>g :Rg<CR> - "nnoremap <leader>t :Tags<CR> - nnoremap <leader>m :Marks<CR> - " This is the default extra key bindings - let g:fzf_action = { - \ 'ctrl-t': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-y': 'vsplit' } - let g:fzf_tags_command = 'ctags -R' - " Border color - let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } } - let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' - let $FZF_DEFAULT_COMMAND="rg --files --hidden" - " Customize fzf colors to match your color scheme - let g:fzf_colors = - \ { 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'hl': ['fg', 'Comment'], - \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], - \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], - \ 'hl+': ['fg', 'Statement'], - \ 'info': ['fg', 'PreProc'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'Conditional'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'] } - " Get Files - command! -bang -nargs=? -complete=dir Files - \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0) - " Get text in files with Rg - command! -bang -nargs=* Rg - \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1, - \ fzf#vim#with_preview(), <bang>0) - " Ripgrep advanced - function! RipgrepFzf(query, fullscreen) - let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' - let initial_command = printf(command_fmt, shellescape(a:query)) - let reload_command = printf(command_fmt, '{q}') - let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} - call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) - endfunction - command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0) - " Git grep - command! -bang -nargs=* GGrep - \ call fzf#vim#grep( - \ 'git grep --line-number '.shellescape(<q-args>), 0, - \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0) - command! -bang FM call fzf#run(fzf#wrap({'source': 'cat ~/.fzf-marks | sed "s/.*: \(.*\)$/\1/" | sed "s#~#${HOME}#"', 'sink': 'lcd'}, <bang>0)) -]]) - -vim.cmd([[ - " Enable mouse scrollback - set mouse=a - tnoremap <Esc> <C-\><C-n> - tnoremap <c-b> <c-\><c-n> - function! ClearTerminal() - set scrollback=1 - let &g:scrollback=1 - echo &scrollback - call feedkeys("\i") - call feedkeys("clear\<CR>") - call feedkeys("\<C-\>\<C-n>") - call feedkeys("\i") - sleep 100m - let &scrollback=s:scroll_value - endfunction -]]) - -vim.cmd([[ - " :Rename {newname} - function! RenameFile() - let old_name = expand('%') - let new_name = input('New file name: ', expand('%'), 'file') - if new_name != '' && new_name != old_name - exec ':saveas ' . new_name - exec ':silent !rm ' . old_name - redraw! - endif - endfunction - map <leader>re :call RenameFile()<cr> -]]) - ---vim.cmd([[ --- " Markdown Settings --- autocmd BufNewFile,BufReadPost *.md set filetype=markdown --- let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'sql', 'pug'] --- let g:markdown_minlines = 100 --- let g:instant_markdown_autostart = 0 ---]]) --- ---vim.cmd([[ --- " On The Fly Table mode --- function! s:isAtStartOfLine(mapping) --- let text_before_cursor = getline('.')[0 : col('.')-1] --- let mapping_pattern = '\V' . escape(a:mapping, '\') --- let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') --- return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') --- endfunction ---]]) diff --git a/.config/nvim/lua/user/opts.lua b/.config/nvim/lua/user/opts.lua deleted file mode 100644 index 90fe0f2..0000000 --- a/.config/nvim/lua/user/opts.lua +++ /dev/null @@ -1,250 +0,0 @@ ---[[ opts.lua ]] --- " Load indent files, to automatically do language-dependent indenting. ---vim.cmd([[ --- "filetype plugin indent on ---]]) - --- Let clipboard register be + -vim.cmd([[ - let g:clipbrdDefaultReg = '+' -]]) - ---vim.cmd([[ --- "autocmd BufEnter * :syntax sync fromstart --- "syntax enable --- "set nocompatible --- "autocmd FileType lua set comments=s1:---,m:--,ex:-- ---]]) - --- Fast macros without lazyredraw -vim.cmd([[ - set re=0 - nnoremap @ <cmd>execute "noautocmd norm! " . v:count1 . "@" . getcharstr()<cr> - xnoremap @ :<C-U>execute "noautocmd '<,'>norm! " . v:count1 . "@" . getcharstr()<cr> -]]) - --- Environment ---vim.opt.shell = "zsh" -- -vim.o.updatetime = 250 -vim.o.shell = "/bin/zsh" -vim.scriptencoding = "utf-8" -- -vim.opt.encoding = "utf-8" -- -vim.opt.fileencoding = "utf-8" -- -vim.g.python3_host_prog = "/usr/bin/python3" -- -vim.g.loaded_python3_provider = 1 -- -vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file -vim.o.autochdir = true ---vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals" -- - --- Colors -vim.opt.termguicolors = true - --- Behaviour -vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup -vim.opt.backspace = { "start", "eol", "indent" } -- Make backspace work as you would expect. -vim.opt.hidden = true -- Switch between buffers without having to save first. -vim.opt.splitbelow = true -- make split put the new buffer below the current buffer -vim.opt.splitright = true -- make vsplit put the new buffer on the right of the current buffer -vim.opt.scrolloff = 8 -- -vim.opt.sidescrolloff = 8 -- how many lines to scroll when using the scrollbar -vim.opt.autoread = true -- reload files if changed externally -vim.opt.display = "lastline" -- Show as much as possible of the last line. -vim.opt.inccommand = "split" -- -vim.opt.ttyfast = true -- Faster redrawing. ---vim.opt.lazyredraw = true -- Only redraw when necessary -vim.opt.keywordprg = ":help" -- :help options -vim.opt.ruler = true -- -vim.opt.errorbells = false -- -vim.opt.list = true -- Show non-printable characters. -vim.opt.showmatch = true -- -vim.opt.matchtime = 3 -- -vim.opt.showbreak = "↪ " -- -vim.opt.linebreak = true -- -vim.opt.exrc = true -- ---vim.opt.autochdir = true -- or use this to use <:e> to create a file in current directory -vim.opt.autoread = true -- if a file is changed outside of vim, automatically reload it without asking ---vim.opt.notimeout = true -- Timeout on keycodes and not mappings -vim.opt.ttimeout = true -- Makes terminal vim work sanely -vim.opt.ttimeoutlen = 10 -- ---vim.opt.timeoutlen = 100 -- time to wait for a mapped sequence to complete (in milliseconds) ---vim.cmd([[set diffopt = vertical = true]]) -- diffs are shown side-by-side not above/below - --- Indent/tab -vim.opt.breakindent = true -- -vim.opt.autoindent = true -- Indent according to previous line. -vim.opt.copyindent = true -- Copy indent from the previous line -vim.opt.smarttab = false -- -vim.opt.tabstop = 2 -- -vim.opt.expandtab = true -- Indent according to previous line. ---vim.opt.expandtab = true -- Use spaces instead of tabs. -vim.opt.softtabstop = 2 -- Tab key indents by 2 spaces. -vim.opt.shiftwidth = 2 -- >> indents by 2 spaces. -vim.opt.shiftround = true -- >> indents to next multiple of 'shiftwidth'. -vim.opt.smartindent = true -- smart indent - --- Column/statusline/Cl -vim.opt.number = true -- -vim.opt.title = true -- ---vim.opt.colorcolumn = "+1" -- -vim.opt.signcolumn = "yes:1" -- always show the sign column ---vim.opt.signcolumn = "yes:" .. vim.o.numberwidth ---vim.opt.signcolumn = "number" ---vim.opt.signcolumn = "no" -- -vim.opt.laststatus = 3 -- " Always show statusline. -vim.opt.showmode = true -- Show current mode in command-line, example: -- INSERT -- mode -vim.opt.showcmd = true -- Show the command in the status bar -vim.opt.cmdheight = 1 -- ---vim.opt.cmdheight = 0 -- -vim.opt.report = 0 -- Always report changed lines. ---local autocmd = vim.api.nvim_create_autocmd ---autocmd("bufenter", { --- pattern = "*", --- callback = function() --- if vim.bo.ft ~= "terminal" then --- vim.opt.statusline = "%!v:lua.require'ui.statusline'.run()" --- else --- vim.opt.statusline = "%#normal# " --- end --- end, ---}) ----- With vertical splits, the statusline would still show up at the ----- bottom of the split. A quick fix is to just set the statusline ----- to empty whitespace (it can't be an empty string because then ----- it'll get replaced by the default stline). ---vim.opt.stl = " " - --- Backup/undo -vim.opt.backup = false -- ---vim.opt.noswapfile = true -- ---vim.opt.undofile = true -- -vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" } -- - --- Format ---vim.opt.textwidth = 80 -- -vim.cmd([[let &t_Cs = "\e[4:3m"]]) -- Undercurl -vim.cmd([[let &t_Ce = "\e[4:0m"]]) -- -vim.opt.path:append({ "**" }) -- Finding files - Search down into subfolder -vim.cmd("set whichwrap+=<,>,[,],h,l") -- -vim.cmd([[set iskeyword+=-]]) -- ---vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work -vim.opt.formatoptions = vim.opt.formatoptions - - "t" -- wrap with text width - + "c" -- wrap comments - + "r" -- insert comment after enter - - "o" -- insert comment after o/O - - "q" -- allow formatting of comments with gq - - "a" -- format paragraphs - + "n" -- recognized numbered lists - - "2" -- use indent of second line for paragraph - + "l" -- long lines are not broken - + "j" -- remove comment when joining lines -vim.opt.wrapscan = true -- " Searches wrap around end-of-file. ---vim.wo.number = true -- ---vim.opt.wrap = false -- No Wrap lines ---vim.opt.foldmethod = 'manual' -- ---vim.opt.foldmethod = "expr" -- -vim.opt.foldmethod = "manual" -vim.opt.foldlevel = 3 -vim.opt.confirm = true -vim.opt.shortmess:append("sI") ---vim.opt.shortmess = "a" ---vim.opt.shortmess = "sI" ---vim.o.shortmess = vim.o.shortmess:gsub('s', '') -vim.opt.fillchars = { - horiz = "━", - horizup = "┻", - horizdown = "┳", - vert = "┃", - vertleft = "┨", - vertright = "┣", - verthoriz = "╋", - fold = "⠀", - eob = " ", - diff = "┃", - msgsep = "‾", - foldopen = "▾", - foldsep = "│", - foldclose = "▸", -} -vim.opt.listchars = { tab = "▸ ", trail = "·" } -- ---vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer -vim.opt.modeline = true -- -vim.opt.modelines = 3 -- modelines (comments that set vim options on a per-file basis) ---vim.opt.modelineexpr = true ---vim.opt.nofoldenable = true -- turn folding off ---vim.opt.foldenable = false -- turn folding off -vim.o.showtabline = 2 - --- Highlights -vim.opt.incsearch = true -- Highlight while searching with / or ?. -vim.opt.hlsearch = true -- Keep matches highlighted. -vim.opt.ignorecase = true -- ignore case in search patterns UNLESS /C or capital in search -vim.opt.smartcase = true -- smart case -vim.opt.synmaxcol = 200 -- Only highlight the first 200 columns. -vim.opt.winblend = 30 ---vim.opt.winblend = 5 -vim.opt.wildoptions = "pum" -- ---vim.opt.pumblend = 5 -- -vim.opt.pumblend = 12 -- ---vim.opt.pumblend=15 -vim.opt.pumheight = 10 -- pop up menu height - --- Better Completion -vim.opt.complete = { ".", "w", "b", "u", "t" } -- ---vim.opt.completeopt = { "longest,menuone,preview" } -- -vim.opt.completeopt = {'menu', 'menuone', 'noselect'} ---vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp ---vim.opt.completeopt = { "menu", "menuone", "noselect" } -- - --- Wildmenu completion -- -vim.opt.wildmenu = true -- -vim.opt.wildmode = { "list:longest" } -- -vim.opt.wildignore:append({ ".hg", ".git", ".svn" }) -- Version control -vim.opt.wildignore:append({ "*.aux", "*.out", "*.toc" }) -- LaTeX intermediate files -vim.opt.wildignore:append({ "*.jpg", "*.bmp", "*.gif", "*.png", "*.jpeg" }) -- binary images -vim.opt.wildignore:append({ "*.o", "*.obj", "*.exe", "*.dll", "*.manifest" }) -- compiled object files -vim.opt.wildignore:append({ "*.spl" }) -- compiled spelling word lists -vim.opt.wildignore:append({ "*.sw?" }) -- Vim swap files -vim.opt.wildignore:append({ "*.DS_Store" }) -- OSX bullshit -vim.opt.wildignore:append({ "*.luac" }) -- Lua byte code -vim.opt.wildignore:append({ "migrations" }) -- Django migrations -vim.opt.wildignore:append({ "*.pyc" }) -- Python byte code -vim.opt.wildignore:append({ "*.orig" }) -- Merge resolution files -vim.opt.wildignore:append({ "*/node_modules/*" }) -- - --- Shada -vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" - --- Sessions -vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" - --- Cursorline -vim.cmd([[ " Only show cursorline in the current window and in normal mode - augroup cline - au! - au WinLeave,InsertEnter * set nocursorline - au WinEnter,InsertLeave * set cursorline - augroup END -]]) -vim.opt.cursorline = true -- -vim.opt.guicursor = "i:ver100,r:hor100" -- - --- Trailing whitespace -vim.cmd([[ " Only show in insert mode - augroup trailing - au! - au InsertEnter * :set listchars-=trail:⌴ - au InsertLeave * :set listchars+=trail:⌴ - augroup END -]]) - --- Line Return ---vim.cmd([[ " Return to the same line when we reopen a file --- augroup line_return --- au! --- au BufReadPost * --- \ if line("'\"") > 0 && line("'\"") <= line("$") | --- \ execute 'normal! g`"zvzz' | --- \ endif --- augroup END ---]]) diff --git a/.config/nvim/lua/user/pack.lua b/.config/nvim/lua/user/pack.lua deleted file mode 100644 index 1a37d8b..0000000 --- a/.config/nvim/lua/user/pack.lua +++ /dev/null @@ -1,421 +0,0 @@ -local fn = vim.fn - --- Automatically install packer -local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" -if fn.empty(fn.glob(install_path)) > 0 then - PACKER_BOOTSTRAP = fn.system({ - "git", - "clone", - "--depth", - "1", - "https://github.com/wbthomason/packer.nvim", - install_path, - }) - print("Installing packer close and reopen Neovim...") - vim.cmd([[packadd packer.nvim]]) -end - --- Autocommand that reloads neovim whenever you save this file -vim.cmd([[ - augroup packer_user_config - autocmd! - autocmd BufWritePost pack.lua source <afile> | PackerSync - augroup end -]]) - --- Use a protected call so we don't error out on first use -local status_ok, packer = pcall(require, "packer") -if not status_ok then - return -end - --- Have packer use a popup window and set a maximum number of jobs -packer.init({ - auto_reload_compiled = true, - max_jobs = 90, - display = { - open_fn = function() - return require("packer.util").float({ border = "rounded" }) - end, - }, -}) - --- Install your plugins here -return packer.startup(function(use) - use("wbthomason/packer.nvim") -- Have packer manage itself - - use("lewis6991/impatient.nvim") - use("nvim-lua/plenary.nvim") -- Useful lua functions used by lots of plugins - --use("jose-elias-alvarez/null-ls.nvim") - - -- lsp - use { - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", - } - require("mason").setup() - local mason_lspconfig = require("mason-lspconfig") - mason_lspconfig.setup({ - ensure_installed = { - "pylsp", - "pyright", - "clangd", - --"vim-language-server", - --"bash-language-server", - --"lua-language-server", - "sumneko_lua", - } - }) - use({ "j-hui/fidget.nvim", - config = function() - require("fidget").setup() - end - }) - --use({ "folke/trouble.nvim", - -- config = function() - -- require("trouble").setup({ position = "right", }) - -- end - --}) - --use({ - --"folke/trouble.nvim", - --requires = "kyazdani42/nvim-web-devicons", - --config = function() - -- require("trouble").setup({ - -- --postion = "top", - -- postion = "right", - -- -- your configuration comes here - -- -- or leave it empty to use the default settings - -- -- refer to the configuration section below - -- }) - --end, - --}) - - --use({ - -- "https://git.sr.ht/~whynothugo/lsp_lines.nvim", -- See also: https://github.com/Maan2003/lsp_lines.nvim - -- config = function() - -- require("lsp_lines").setup() - - -- -- disable virtual_text since it's redundant due to lsp_lines. - -- vim.diagnostic.config({ - -- virtual_text = false, - -- }) - -- end, - --}) - use { "simrat39/symbols-outline.nvim", - config = function() - require("symbols-outline").setup({ - auto_close = true, - }) - end - } - use "antoinemadec/FixCursorHold.nvim" - use { "kosayoda/nvim-lightbulb", requires = { "antoinemadec/FixCursorHold.nvim" } } - --use("folke/lsp-colors.nvim") - use "mfussenegger/nvim-lint" - use "weilbith/nvim-code-action-menu" - use "simrat39/rust-tools.nvim" - use { "saecki/crates.nvim", - requires = { "nvim-lua/plenary.nvim" }, - config = function() - require("crates").setup() - end, - } - --use "lvimuser/lsp-inlayhints.nvim" -- rust-tools already provides this feature, but gopls doesn't - - -- null-ls - --use({ "jose-elias-alvarez/null-ls.nvim", - -- config = function() - -- require("null-ls").setup({ - -- sources = { - -- require("null-ls").builtins.diagnostics.checkmake, -- https://github.com/mrtazz/checkmake - -- } - -- }) - -- end - --}) - use({ - "jose-elias-alvarez/null-ls.nvim", - config = function() - require("null-ls").setup() - end, - requires = { "nvim-lua/plenary.nvim" }, - }) - use({ - "SmiteshP/nvim-navic", - requires = "neovim/nvim-lspconfig", - }) - - -- nvimlsp plugins - --use({ - -- "williamboman/mason.nvim", - -- config = function() - -- require("mason").setup() - -- require("mason-lspconfig").setup({ - -- ensure_installed = { "sumneko_lua", "clangd", "rust_analyzer" }, - -- }) - -- end, - --}) - --use("williamboman/mason.nvim") - --use("williamboman/mason-lspconfig.nvim") - --use("neovim/nvim-lspconfig") - --use("williamboman/nvim-lsp-installer") - --use("glepnir/lspsaga.nvim") - --use("nvim-lua/lsp-status.nvim") - --use({ - -- "glepnir/lspsaga.nvim", - -- branch = "main", - -- config = function() - -- local saga = require("lspsaga") - - -- saga.init_lsp_saga({ - -- -- your configuration - -- }) - -- end, - --}) - -- use("nvim-lua/popup.nvim") - --use("SmiteshP/nvim-gps") - -- autocomplete plugins - use("hrsh7th/nvim-cmp") - use("hrsh7th/cmp-nvim-lsp") - use("hrsh7th/cmp-buffer") - use("hrsh7th/cmp-path") - use("hrsh7th/cmp-cmdline") - use("petertriho/cmp-git") - use("tamago324/cmp-zsh") - use("f3fora/cmp-spell") - use("hrsh7th/cmp-calc") - use("saadparwaiz1/cmp_luasnip") - use("hrsh7th/cmp-nvim-lsp-signature-help") - use("onsails/lspkind-nvim") - - -- snippets - --use("L3MON4D3/LuaSnip") --snippet engine - use("L3MON4D3/LuaSnip") - use("rafamadriz/friendly-snippets") -- a bunch of snippets to use - --use("github/copilot.vim") - --use({ - --"zbirenbaum/copilot.lua", - --event = { "VimEnter" }, - --config = function() - --vim.defer_fn(function() - --require("plugins.copilot") - --end, 100) - --end, - --}) - --use({ - --"zbirenbaum/copilot-cmp", - --module = "copilot_cmp", - --}) - - -- treesitter plugins - use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) --folding, jumping, refactoring... - use("nvim-treesitter/nvim-treesitter-refactor") - use("nvim-treesitter/nvim-treesitter-context") - --use({ - -- "danymat/neogen", - -- config = function() - -- require("neogen").setup({ snippet_engine = "luasnip" }) - -- end, - -- requires = "nvim-treesitter/nvim-treesitter", - --}) - --use({ "junegunn/fzf", run = ":call fzf#install()" }) - use('ibhagwan/fzf-lua') - -- telescope plugins - use("nvim-telescope/telescope.nvim") - use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) - use("tami5/sqlite.lua") - --use("nvim-telescope/telescope-frecency.nvim") - use("nvim-telescope/telescope-ui-select.nvim") - use("nvim-telescope/telescope-media-files.nvim") - use("nvim-telescope/telescope-file-browser.nvim") - -- search emoji and other symbols - use({ "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" }) - use("axkirillov/telescope-changed-files") - --use({ - --"princejoogie/dir-telescope.nvim", - --requires = {"nvim-telescope/telescope.nvim"}, - --config = function() - -- require("dir-telescope").setup({ - -- hidden = true, - -- respect_gitignore = true, - -- }) - --end, - --}) - use("airblade/vim-rooter") - -- statusline plugins - --use("nvim-lualine/lualine.nvim") - --use({ - -- "nvim-lualine/lualine.nvim", - -- requires = { "kyazdani42/nvim-web-devicons", opt = true }, - --}) - --use({ - -- "folke/trouble.nvim", - -- requires = "kyazdani42/nvim-web-devicons", - -- config = function() - -- require("trouble").setup({ - -- -- your configuration comes here - -- -- or leave it empty to use the default settings - -- -- refer to the configuration section below - -- }) - -- end, - --}) - use("rebelot/heirline.nvim") - --use({ "akinsho/bufferline.nvim", tag = "v2.*", requires = "kyazdani42/nvim-web-devicons" }) - --use("itchyny/lightline.vim") - -- debug plugins - --use("puremourning/vimspector") - use("mfussenegger/nvim-dap") - use("rcarriga/nvim-dap-ui") - --use({ - -- "rcarriga/neotest", - -- requires = { - -- "nvim-lua/plenary.nvim", - -- "nvim-treesitter/nvim-treesitter", - -- "antoinemadec/FixCursorHold.nvim", - -- "rcarriga/neotest-python", - -- "rcarriga/neotest-vim-test", - -- "rcarriga/neotest-plenary", - -- "vim-test/vim-test", - -- }, - -- config = function() - -- require("plugins.neotest") - -- end, - --}) - --use("vim-test/vim-test") - --use({ - -- "rcarriga/vim-ultest", - -- requires = { "vim-test/vim-test" }, - -- run = ":UpdateRemotePlugins", - -- config = function() - -- require("plugins.ultest") - -- end, - --}) - -- UI - use("karb94/neoscroll.nvim") - use("folke/which-key.nvim") - use("MunifTanjim/prettier.nvim") -- Prettier plugin for Neovim's built-in LSP client - use("norcalli/nvim-colorizer.lua") - use("folke/zen-mode.nvim") - use("romainl/vim-cool") - --use("p00f/nvim-ts-rainbow") - --use("goolord/alpha-nvim") - --use("feline-nvim/feline.nvim") - --use({ "fgheng/winbar.nvim" }) - --use("vim-airline/vim-airline") - --use("kdheepak/tabline.nvim") - -- use({ - -- "kdheepak/tabline.nvim", - -- config = function() - -- require("tabline").setup({ enable = false }) - -- end, - -- requires = { "hoob3rt/lualine.nvim", "kyazdani42/nvim-web-devicons" }, - -- notification plugin - use("rcarriga/nvim-notify") - --use("lukas-reineke/indent-blankline.nvim") - use("kyazdani42/nvim-web-devicons") - -- Colorschemes - use("gruvbox-community/gruvbox") - use("srcery-colors/srcery-vim") - use("tomasr/molokai") - use("ayu-theme/ayu-vim") - --use("sjl/badwolf") - use("joshdick/onedark.vim") - use("everblush/everblush.nvim") - use("EdenEast/nightfox.nvim") - use("bluz71/vim-nightfly-guicolors") - --use({ "shaunsingh/oxocarbon.nvim", run = "./install.sh" }) - use("jacoborus/tender.vim") - use("sainnhe/sonokai") - use("NTBBloodbath/doom-one.nvim") - - -- Utilities - use("nathom/filetype.nvim") - --use("christoomey/vim-tmux-navigator") - use("preservim/vimux") - use("myusuf3/numbers.vim") - use("windwp/nvim-autopairs") - use("lewis6991/gitsigns.nvim") - use("dinhhuy258/git.nvim") -- For git blame & browse - use("kdheepak/lazygit.nvim") - use("kyazdani42/nvim-tree.lua") - use("numToStr/Comment.nvim") - use("akinsho/toggleterm.nvim") - --use("godlygeek/tabular") - --use("Vonr/align.nvim") - --use("junegunn/vim-easy-align") - --use("dstein64/vim-startuptime") - use("tweekmonster/startuptime.vim") - -- use("luukvbaal/stabilize.nvim") - --use("rhysd/clever-f.vim") - --use("ggandor/lightspeed.nvim") -- use 'cl' and 'cc' instead of 's' and 'S' respectively - --use("ggandor/leap.nvim") - use({ - "ggandor/leap.nvim", - config = function() - require('leap').add_default_mappings() - --require("leap").set_default_keymaps() - --vim.keymap.set('n', '-', '<Plug>(leap-forward)', {}) - --vim.keymap.set('n', '_', '<Plug>(leap-backward)', {}) - end, - }) - use({ "ggandor/flit.nvim", - config = function() - require("flit").setup() - end, - }) - - --use("Shatur/neovim-session-manager") - --use("rmagatti/auto-session") - --use("rmagatti/session-lens") - --use("ahmedkhalf/project.nvim") - --use("aserowy/tmux.nvim") - --use({ - -- "aserowy/tmux.nvim", - -- config = function() return require("tmux").setup() { - -- copy_sync = { - -- enable = false, - -- }, - -- } - -- end, - --}) - use({ - 'numToStr/Navigator.nvim', - config = function() - require('Navigator').setup() - end, - }) - --use("wakatime/vim-wakatime") - --use("tpope/vim-eunuch") - -- Handy unix command inside Vim (Rename, Move etc.) - use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }) - use("tpope/vim-fugitive") - --use("tpope/vim-surround") - --use("tpope/vim-obsession") - --use("tpope/vim-unimpaired") - --use("voldikss/vim-floaterm") - --use("vimpostor/vim-tpipeline") - --use({ - -- "vimwiki/vimwiki", - -- config = function() - -- vim.g.vimwiki_list = { - -- { - -- path = "~/", - -- syntax = "markdown", - -- ext = ".md", - -- }, - -- } - -- vim.g.vimwiki_ext2syntax = { - -- [".md"] = "markdown", - -- [".markdown"] = "markdown", - -- [".mdown"] = "markdown", - use({ - "iamcco/markdown-preview.nvim", - run = function() vim.fn["mkdp#util#install"]() end, - }) - - -- Automatically set up your configuration after cloning packer.nvim - -- Put this at the end after all plugins - if PACKER_BOOTSTRAP then - require("packer").sync() - end -end) diff --git a/.config/nvim/lua/user/utils.lua b/.config/nvim/lua/user/utils.lua deleted file mode 100644 index bfb5faa..0000000 --- a/.config/nvim/lua/user/utils.lua +++ /dev/null @@ -1,85 +0,0 @@ -local fn = vim.fn - -local M = {} - -function M.executable(name) - if fn.executable(name) > 0 then - return true - end - - return false -end - ---- check whether a feature exists in Nvim ---- @feat: string ---- the feature name, like `nvim-0.7` or `unix`. ---- return: bool -M.has = function(feat) - if fn.has(feat) == 1 then - return true - end - - return false -end - ---- Create a dir if it does not exist -function M.may_create_dir(dir) - local res = fn.isdirectory(dir) - - if res == 0 then - fn.mkdir(dir, "p") - end -end - -M['unload_lua_namespace'] = function(prefix) - local prefix_with_dot = prefix .. '.' - for key, value in pairs(package.loaded) do - if key == prefix or key:sub(1, #prefix_with_dot) == prefix_with_dot then - package.loaded[key] = nil - end - end -end - --- toggle cmp completion -vim.g.cmp_toggle_flag = false -- initialize -local normal_buftype = function() - return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" -end -M.toggle_completion = function() - local ok, cmp = pcall(require, "cmp") - if ok then - local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag - if next_cmp_toggle_flag then - print("completion on") - else - print("completion off") - end - cmp.setup({ - enabled = function() - vim.g.cmp_toggle_flag = next_cmp_toggle_flag - if next_cmp_toggle_flag then - return normal_buftype - else - return next_cmp_toggle_flag - end - end, - }) - else - print("completion not available") - end -end - -function M.get_nvim_version() - local actual_ver = vim.version() - - local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch) - return nvim_ver_str -end - -function M.add_pack(name) - local status, error = pcall(vim.cmd, "packadd " .. name) - - return status -end - -return M |
