diff --git a/.config/fish/config.fish b/.config/fish/config.fish index e543714..5ce316a 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -4,7 +4,7 @@ alias icloud="cd ~/Library/Mobile\ Documents/com~apple~CloudDocs" alias pi="ssh pi@185.138.33.80 -p 1733" alias zshrc="nvim ~/.zshrc" alias fishconfig="cd ~/.config/fish && nvim config.fish && cd -" -alias nvimconfig="cd ~/.config/nvim && nvim init.vim && cd -" +alias nvimconfig="cd ~/.config/nvim && nvim && cd -" alias ai="sgpt -se" alias y="open -a Yoink" diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore new file mode 100644 index 0000000..6fe3cb0 --- /dev/null +++ b/.config/nvim/.gitignore @@ -0,0 +1 @@ +.plugins.lua.swp diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 9162cd1..f636e40 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -86,372 +86,8 @@ au VimLeave * set guicursor=a:ver100 " Use Bash as shell for internal Vim commands (fish is slow) set shell=/bin/bash +" Load plugins from separate file +lua require("plugins") -" PLUGINS - installation and configuration - -" Install Plug (plugin manager) if not already installed -let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' -if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * q -endif - -" Install plugins automatically when launching Neovim -autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) - \| PlugInstall --sync | source $MYVIMRC -\| endif - -" Fetch plugins with Plug -call plug#begin() - -" Color theme -Plug 'sonph/onehalf', { 'rtp': 'vim' } -" Plug 'arcticicestudio/nord-vim' - -" VSCode-like language server -Plug 'neoclide/coc.nvim', {'branch': 'release'} - -" Syntax highlighting for almost every language -Plug 'sheerun/vim-polyglot' - -" Add two-character motions with s and S -Plug 'ggandor/leap.nvim' -Plug 'tpope/vim-repeat' - -" VSCode-like multi-cursor support -Plug 'mg979/vim-visual-multi', {'branch': 'master'} - -" Easy commenting/uncommenting -Plug 'numToStr/Comment.nvim' - -" Easy handling of surroundings (tags, brackets etc.) -Plug 'tpope/vim-surround' - -" Github Copilot -Plug 'github/copilot.vim' - -" Auto-restore session when opening Neovim -Plug 'rmagatti/auto-session' - -" File explorer sidebar -Plug 'kyazdani42/nvim-web-devicons' -Plug 'kyazdani42/nvim-tree.lua', { 'commit': 'e14989c' } - -" Fuzzy finder for files, buffers, etc. (including dependencies) -Plug 'nvim-lua/plenary.nvim' -Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.0' } -Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } - -" Persistent terminal that can be toggled with a keybinding -Plug 'akinsho/toggleterm.nvim', {'tag': '2.3.0'} - -" Easily run code with a keybinding -Plug 'CRAG666/code_runner.nvim' - -" Live Markdown preview in browser -Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && npm install' } - -" Git integration: show modified lines next to line numbers -Plug 'lewis6991/gitsigns.nvim' - -" Tool for resolving Git merge conflicts -Plug 'rhysd/conflict-marker.vim' - -" VSCode-like scrollbar with Git and diagnostic markers -Plug 'petertriho/nvim-scrollbar' - -" Smooth scrolling -Plug 'karb94/neoscroll.nvim' - -" End of plugin fetching -call plug#end() - -" Set color scheme -if exists('+termguicolors') - let &t_8f = "\[38;2;%lu;%lu;%lum" - let &t_8b = "\[48;2;%lu;%lu;%lum" - set termguicolors -endif -colorscheme onehalfdark -let g:terminal_color_8 = '#6f7a90' - -" Install Coc extenstions -let g:coc_global_extensions = [ - \ 'coc-pyright', - \ 'coc-clangd', - \ 'coc-tsserver', - \ '@yaegassy/coc-volar', - \ 'coc-svelte', - \ 'coc-emmet', - \ 'coc-prettier', - \ 'coc-eslint', - \ ] - -" Custom options for Coc -let g:python_highlight_space_errors = 0 -command! -nargs=0 Format :CocCommand format -command! -nargs=0 F :Format -command! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument - -" Configure vim-polyglot -let g:vim_svelte_plugin_load_full_syntax = 1 -let g:vim_svelte_plugin_use_typescript = 1 -let g:vim_svelte_plugin_use_sass = 1 - -" Configure leap -lua require('leap').add_default_mappings() - -" Configure Comment.nvim -lua require('Comment').setup() - -" Disable Github Copilot on launch and configure commands -autocmd BufRead * let b:copilot_enabled = v:false -command! -nargs=0 CPE :let b:copilot_enabled = v:true -command! -nargs=0 CPD :let b:copilot_enabled = v:false - -" Configure auto-session -lua require("auto-session").setup{ - \ log_level = "error", - \ } - -" Configure nvim-tree -let g:loaded_netrw = 1 -let g:loaded_netrwPlugin = 1 -nmap gx :!open -nnoremap n :NvimTreeToggle -lua require("nvim-tree").setup({ - \ update_focused_file = { - \ enable = true, - \ }, - \ view = { - \ signcolumn = "auto", - \ adaptive_size = true, - \ mappings = { - \ list = { - \ { key = "+", action = "cd" }, - \ }, - \ }, - \ }, - \ }) - -" Configure Telescope -lua require('telescope').setup{} -lua require('telescope').load_extension('fzf') -nnoremap p Telescope find_files -nnoremap f Telescope live_grep -nnoremap b Telescope buffers -nnoremap o Telescope oldfiles -nnoremap t Telescope tags -nnoremap : Telescope commands -nnoremap d Telescope git_status -nnoremap Telescope resume - -" Configure ToggleTerm -lua require("toggleterm").setup{ - \ size = 20, - \ hide_numbers = true, - \ direction = 'horizontal', - \ open_mapping = [[]], - \ shade_terminals = true, - \ shading_factor = 2, - \ shell = 'fish' - \ } - -" Configure code_runner -lua require('code_runner').setup{ - \ mode = "toggleterm", - \ filetype = { - \ python = "python", - \ javascript = "node", - \ typescript = "node", - \ c = "gcc -o main % && ./main", - \ }, - \ } -nnoremap :w:RunCode - -" Configure markdown-preview -let g:mkdp_auto_close = 0 - -" Configure gitsigns.nvim -lua require('gitsigns').setup() -lua require("scrollbar.handlers.gitsigns").setup() - -" Configure conflict-marker -let g:conflict_marker_highlight_group = '' -let g:conflict_marker_begin = '^<<<<<<< .*$' -let g:conflict_marker_end = '^>>>>>>> .*$' -highlight ConflictMarkerBegin guibg=#2f7366 -highlight ConflictMarkerOurs guibg=#2e5049 -highlight ConflictMarkerTheirs guibg=#344f69 -highlight ConflictMarkerEnd guibg=#2f628e -highlight ConflictMarkerCommonAncestorsHunk guibg=#754a81 - -" Configure nvim-scrollbar -lua require("scrollbar").setup({ - \ marks = { - \ Search = { color = "#ff9e64" }, - \ Error = { color = "#db4b4b" }, - \ Warn = { color = "#e0af68" }, - \ Info = { color = "#0db9d7" }, - \ Hint = { color = "#1abc9c" }, - \ Misc = { color = "#9d7cd8" }, - \ GitAdd = { color = "#9ece6a" }, - \ GitChange = { color = "#e0af68" }, - \ GitDelete = { color = "#914c54" }, - \ } - \ }) - -" Configure neoscroll -lua require('neoscroll').setup({ easing_function = 'sine' }) - - - -" COC DEFAULT CONFIG - required for autocompletion etc. to work properly -" Copied from the readme: github.com/neoclide/coc.nvim - -" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable -" delays and poor user experience. -set updatetime=300 - -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. -set signcolumn=yes - -" Use tab for trigger completion with characters ahead and navigate. -" NOTE: There's always complete item selected by default, you may want to enable -" no select by `"suggest.noselect": true` in your configuration file. -" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by -" other plugin before putting this into your config. -inoremap - \ coc#pum#visible() ? coc#pum#next(1) : - \ CheckBackspace() ? "\" : - \ coc#refresh() -inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" - -" Make to accept selected completion item or notify coc.nvim to format -" u breaks current undo, please make your own choice. -inoremap coc#pum#visible() ? coc#pum#confirm() - \: "\u\\=coc#on_enter()\" - -function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -" Use to trigger completion. -if has('nvim') - inoremap coc#refresh() -else - inoremap coc#refresh() -endif - -" Use `[g` and `]g` to navigate diagnostics -" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - -" GoTo code navigation. -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -" Use K to show documentation in preview window. -nnoremap K :call ShowDocumentation() - -function! ShowDocumentation() - if CocAction('hasProvider', 'hover') - call CocActionAsync('doHover') - else - call feedkeys('K', 'in') - endif -endfunction - -" Highlight the symbol and its references when holding the cursor. -autocmd CursorHold * silent call CocActionAsync('highlight') - -" Symbol renaming. -nmap rn (coc-rename) - -" Formatting selected code. -" xmap f (coc-format-selected) -" nmap f (coc-format-selected) - -augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder. - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') -augroup end - -" Applying codeAction to the selected region. -" Example: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) - -" Remap keys for applying codeAction to the current buffer. -nmap ac (coc-codeaction) -" Apply AutoFix to problem on the current line. -nmap qf (coc-fix-current) - -" Run the Code Lens action on the current line. -nmap cl (coc-codelens-action) - -" Map function and class text objects -" NOTE: Requires 'textDocument.documentSymbol' support from the language server. -xmap if (coc-funcobj-i) -omap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap af (coc-funcobj-a) -xmap ic (coc-classobj-i) -omap ic (coc-classobj-i) -xmap ac (coc-classobj-a) -omap ac (coc-classobj-a) - -" Remap and for scroll float windows/popups. -if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" -endif - -" Use CTRL-S for selections ranges. -" Requires 'textDocument/selectionRange' support of language server. -nmap (coc-range-select) -xmap (coc-range-select) - -" Add `:Format` command to format current buffer. -command! -nargs=0 Format :call CocActionAsync('format') - -" Add `:Fold` command to fold current buffer. -command! -nargs=? Fold :call CocAction('fold', ) - -" Add `:OR` command for organize imports of the current buffer. -command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') - -" Add (Neo)Vim's native statusline support. -" NOTE: Please see `:h coc-status` for integrations with external plugins that -" provide custom statusline: lightline.vim, vim-airline. -" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} - -" Mappings for CoCList -" Show all diagnostics. -nnoremap a :CocList diagnostics -" Manage extensions. -nnoremap e :CocList extensions -" Show commands. -nnoremap c :CocList commands -" Find symbol of current document. -nnoremap o :CocList outline -" Search workspace symbols. -nnoremap s :CocList -I symbols -" Do default action for next item. -nnoremap j :CocNext -" Do default action for previous item. -nnoremap k :CocPrev -" Resume latest coc list. -nnoremap p :CocListResume +" Load default Coc config from separate file +lua require("coc-defaults") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..25a2312 --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,25 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "8d3aa5c22c2d45e788c7a5fe13ad77368b783c20" }, + "auto-session": { "branch": "main", "commit": "1d3dd70a2d48e0f3441128eb4fb0b437a0bf2cc4" }, + "coc.nvim": { "branch": "release", "commit": "bbaa1d5d1ff3cbd9d26bb37cfda1a990494c4043" }, + "code_runner.nvim": { "branch": "main", "commit": "a010649236fe245eaab2641a13228cd601499715" }, + "copilot.vim": { "branch": "release", "commit": "9e869d29e62e36b7eb6fb238a4ca6a6237e7d78b" }, + "git-conflict.nvim": { "branch": "main", "commit": "80bc8931d4ed8c8c4d289a08e1838fcf4741408d" }, + "gitsigns.nvim": { "branch": "main", "commit": "b1f9cf7c5c5639c006c937fc1819e09f358210fc" }, + "lazy.nvim": { "branch": "main", "commit": "887eb75591520a01548134c4623617b639289d0b" }, + "leap.nvim": { "branch": "main", "commit": "f74473d23ebf60957e0db3ff8172349a82e5a442" }, + "markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" }, + "neoscroll.nvim": { "branch": "master", "commit": "d7601c26c8a183fa8994ed339e70c2d841253e93" }, + "nvim-scrollbar": { "branch": "main", "commit": "f85b29805cf917f9b1d5ff0c9a52c5b1bdca5943" }, + "nvim-toggleterm.lua": { "branch": "main", "commit": "2a787c426ef00cb3488c11b14f5dcf892bbd0bda" }, + "nvim-tree.lua": { "branch": "master", "commit": "e14989c0eaa6f9c299d48f7e45ce1ed04b21180f" }, + "nvim-web-devicons": { "branch": "master", "commit": "074e13f21f52bb45d654069bdadbcb6d7c2b65d0" }, + "onehalf": { "branch": "master", "commit": "75eb2e97acd74660779fed8380989ee7891eec56" }, + "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, + "telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" }, + "vim-polyglot": { "branch": "master", "commit": "bc8a81d3592dab86334f27d1d43c080ebf680d42" }, + "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vim-visual-multi": { "branch": "master", "commit": "724bd53adfbaf32e129b001658b45d4c5c29ca1a" } +} \ No newline at end of file diff --git a/.config/nvim/lua/coc-defaults.lua b/.config/nvim/lua/coc-defaults.lua new file mode 100644 index 0000000..bbc145e --- /dev/null +++ b/.config/nvim/lua/coc-defaults.lua @@ -0,0 +1,189 @@ +-- Default config for Coc +-- From https://github.com/neoclide/coc.nvim + +-- Some servers have issues with backup files, see #649 +vim.opt.backup = false +vim.opt.writebackup = false + +-- Having longer updatetime (default is 4000 ms = 4s) leads to noticeable +-- delays and poor user experience +vim.opt.updatetime = 300 + +-- Always show the signcolumn, otherwise it would shift the text each time +-- diagnostics appeared/became resolved +vim.opt.signcolumn = "yes" + +local keyset = vim.keymap.set +-- Autocomplete +function _G.check_back_space() + local col = vim.fn.col('.') - 1 + return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil +end + +-- Use Tab for trigger completion with characters ahead and navigate +-- NOTE: There's always a completion item selected by default, you may want to enable +-- no select by setting `"suggest.noselect": true` in your configuration file +-- NOTE: Use command ':verbose imap ' to make sure Tab is not mapped by +-- other plugins before putting this into your config +local opts = {silent = true, noremap = true, expr = true, replace_keycodes = false} +keyset("i", "", 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "" : coc#refresh()', opts) +keyset("i", "", [[coc#pum#visible() ? coc#pum#prev(1) : "\"]], opts) + +-- Make to accept selected completion item or notify coc.nvim to format +-- u breaks current undo, please make your own choice +keyset("i", "", [[coc#pum#visible() ? coc#pum#confirm() : "\u\\=coc#on_enter()\"]], opts) + +-- Use to trigger snippets +keyset("i", "", "(coc-snippets-expand-jump)") +-- Use to trigger completion +keyset("i", "", "coc#refresh()", {silent = true, expr = true}) + +-- Use `[g` and `]g` to navigate diagnostics +-- Use `:CocDiagnostics` to get all diagnostics of current buffer in location list +keyset("n", "[g", "(coc-diagnostic-prev)", {silent = true}) +keyset("n", "]g", "(coc-diagnostic-next)", {silent = true}) + +-- GoTo code navigation +keyset("n", "gd", "(coc-definition)", {silent = true}) +keyset("n", "gy", "(coc-type-definition)", {silent = true}) +keyset("n", "gi", "(coc-implementation)", {silent = true}) +keyset("n", "gr", "(coc-references)", {silent = true}) + + +-- Use K to show documentation in preview window +function _G.show_docs() + local cw = vim.fn.expand('') + if vim.fn.index({'vim', 'help'}, vim.bo.filetype) >= 0 then + vim.api.nvim_command('h ' .. cw) + elseif vim.api.nvim_eval('coc#rpc#ready()') then + vim.fn.CocActionAsync('doHover') + else + vim.api.nvim_command('!' .. vim.o.keywordprg .. ' ' .. cw) + end +end +keyset("n", "K", 'lua _G.show_docs()', {silent = true}) + + +-- Highlight the symbol and its references on a CursorHold event(cursor is idle) +vim.api.nvim_create_augroup("CocGroup", {}) +vim.api.nvim_create_autocmd("CursorHold", { + group = "CocGroup", + command = "silent call CocActionAsync('highlight')", + desc = "Highlight symbol under cursor on CursorHold" +}) + + +-- Symbol renaming +keyset("n", "rn", "(coc-rename)", {silent = true}) + + +-- Formatting selected code +keyset("x", "f", "(coc-format-selected)", {silent = true}) +keyset("n", "f", "(coc-format-selected)", {silent = true}) + + +-- Setup formatexpr specified filetype(s) +vim.api.nvim_create_autocmd("FileType", { + group = "CocGroup", + pattern = "typescript,json", + command = "setl formatexpr=CocAction('formatSelected')", + desc = "Setup formatexpr specified filetype(s)." +}) + +-- Update signature help on jump placeholder +vim.api.nvim_create_autocmd("User", { + group = "CocGroup", + pattern = "CocJumpPlaceholder", + command = "call CocActionAsync('showSignatureHelp')", + desc = "Update signature help on jump placeholder" +}) + +-- Apply codeAction to the selected region +-- Example: `aap` for current paragraph +local opts = {silent = true, nowait = true} +keyset("x", "a", "(coc-codeaction-selected)", opts) +keyset("n", "a", "(coc-codeaction-selected)", opts) + +-- Remap keys for apply code actions at the cursor position. +keyset("n", "ac", "(coc-codeaction-cursor)", opts) +-- Remap keys for apply code actions affect whole buffer. +keyset("n", "as", "(coc-codeaction-source)", opts) +-- Remap keys for applying codeActions to the current buffer +keyset("n", "ac", "(coc-codeaction)", opts) +-- Apply the most preferred quickfix action on the current line. +keyset("n", "qf", "(coc-fix-current)", opts) + +-- Remap keys for apply refactor code actions. +keyset("n", "re", "(coc-codeaction-refactor)", { silent = true }) +keyset("x", "r", "(coc-codeaction-refactor-selected)", { silent = true }) +keyset("n", "r", "(coc-codeaction-refactor-selected)", { silent = true }) + +-- Run the Code Lens actions on the current line +keyset("n", "cl", "(coc-codelens-action)", opts) + + +-- Map function and class text objects +-- NOTE: Requires 'textDocument.documentSymbol' support from the language server +keyset("x", "if", "(coc-funcobj-i)", opts) +keyset("o", "if", "(coc-funcobj-i)", opts) +keyset("x", "af", "(coc-funcobj-a)", opts) +keyset("o", "af", "(coc-funcobj-a)", opts) +keyset("x", "ic", "(coc-classobj-i)", opts) +keyset("o", "ic", "(coc-classobj-i)", opts) +keyset("x", "ac", "(coc-classobj-a)", opts) +keyset("o", "ac", "(coc-classobj-a)", opts) + + +-- Remap and to scroll float windows/popups +---@diagnostic disable-next-line: redefined-local +local opts = {silent = true, nowait = true, expr = true} +keyset("n", "", 'coc#float#has_scroll() ? coc#float#scroll(1) : ""', opts) +keyset("n", "", 'coc#float#has_scroll() ? coc#float#scroll(0) : ""', opts) +keyset("i", "", + 'coc#float#has_scroll() ? "=coc#float#scroll(1)" : ""', opts) +keyset("i", "", + 'coc#float#has_scroll() ? "=coc#float#scroll(0)" : ""', opts) +keyset("v", "", 'coc#float#has_scroll() ? coc#float#scroll(1) : ""', opts) +keyset("v", "", 'coc#float#has_scroll() ? coc#float#scroll(0) : ""', opts) + + +-- Use CTRL-S for selections ranges +-- Requires 'textDocument/selectionRange' support of language server +keyset("n", "", "(coc-range-select)", {silent = true}) +keyset("x", "", "(coc-range-select)", {silent = true}) + + +-- Add `:Format` command to format current buffer +vim.api.nvim_create_user_command("Format", "call CocAction('format')", {}) + +-- " Add `:Fold` command to fold current buffer +vim.api.nvim_create_user_command("Fold", "call CocAction('fold', )", {nargs = '?'}) + +-- Add `:OR` command for organize imports of the current buffer +vim.api.nvim_create_user_command("OR", "call CocActionAsync('runCommand', 'editor.action.organizeImport')", {}) + +-- Add (Neo)Vim's native statusline support +-- NOTE: Please see `:h coc-status` for integrations with external plugins that +-- provide custom statusline: lightline.vim, vim-airline +vim.opt.statusline:prepend("%{coc#status()}%{get(b:,'coc_current_function','')}") + +-- Mappings for CoCList +-- code actions and coc stuff +---@diagnostic disable-next-line: redefined-local +local opts = {silent = true, nowait = true} +-- Show all diagnostics +keyset("n", "a", ":CocList diagnostics", opts) +-- Manage extensions +keyset("n", "e", ":CocList extensions", opts) +-- Show commands +keyset("n", "c", ":CocList commands", opts) +-- Find symbol of current document +keyset("n", "o", ":CocList outline", opts) +-- Search workspace symbols +keyset("n", "s", ":CocList -I symbols", opts) +-- Do default action for next item +keyset("n", "j", ":CocNext", opts) +-- Do default action for previous item +keyset("n", "k", ":CocPrev", opts) +-- Resume latest coc list +keyset("n", "p", ":CocListResume", opts) diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..64f9edb --- /dev/null +++ b/.config/nvim/lua/plugins.lua @@ -0,0 +1,239 @@ +-- Install lazy.nvim (plugin manager) +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +-- Install plugins +require("lazy").setup({ + -- Color scheme + { + "sonph/onehalf", + lazy = false, + priority = 1000, + config = function(plugin) + vim.opt.rtp:append(plugin.dir .. "/vim") + vim.opt.termguicolors = true + vim.cmd([[colorscheme onehalfdark]]) + end + }, + + -- VSCode-like language server + { + "neoclide/coc.nvim", + branch = "release", + init = function() + vim.g.coc_global_extensions = { + "coc-pyright", + "coc-clangd", + "coc-tsserver", + "@yaegassy/coc-volar", + "coc-svelte", + "coc-emmet", + "coc-prettier", + "coc-eslint", + } + end + }, + + -- Syntax highlighting for almost every language + { + "sheerun/vim-polyglot", + init = function() + vim.g.vim_svelte_plugin_load_full_syntax = 1 + vim.g.vim_svelte_plugin_use_typescript = 1 + vim.g.vim_svelte_plugin_use_sass = 1 + end + }, + + -- Enable dot repeat for plugins + { + "tpope/vim-repeat", + }, + + -- Add two-character motions with s and S + { + "ggandor/leap.nvim", + config = function() + require('leap').add_default_mappings() + end + }, + + -- VSCode-like multi-cursor support + { + "mg979/vim-visual-multi", + branch = "master", + }, + + -- Easy commenting/uncommenting + { + "numToStr/Comment.nvim", + config = true, + }, + + -- Easy handling of surroundings + { + "tpope/vim-surround", + }, + + -- GitHub Copilot + { + "github/copilot.vim", + cmd = "CPE", -- Don't load until enable command is run + config = function() + vim.api.nvim_create_user_command("CPE", "Copilot enable", {}) + vim.api.nvim_create_user_command("CPD", "Copilot disable", {}) + end + }, + + -- Auto-restore session when opening Neovim + { + "rmagatti/auto-session", + opts = { + log_level = "error", + }, + }, + + -- File explorer sidebar + { + "kyazdani42/nvim-tree.lua", + commit = "e14989c", -- newer versions break auto-session + dependencies = { + "kyazdani42/nvim-web-devicons", + }, + opts = { + update_focused_file = { + enable = true, + }, + view = { + signcolumn = "auto", + adaptive_size = true, + mappings = { + list = { + { key = "+", action = "cd" }, + }, + }, + }, + }, + init = function() + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + vim.keymap.set("n", "n", ":NvimTreeToggle", { noremap = true, silent = true }) + end, + }, + + -- Fuzzy finder for files, buffers, etc. + { + "nvim-telescope/telescope.nvim", + tag = "0.1.1", + dependencies = { + "nvim-lua/plenary.nvim", + {"nvim-telescope/telescope-fzf-native.nvim", build = "make"}, + }, + config = function() + require("telescope").setup{} + require("telescope").load_extension("fzf") + vim.keymap.set("n", "p", ":Telescope find_files", { noremap = true, silent = true }) + vim.keymap.set("n", "f", ":Telescope live_grep", { noremap = true, silent = true }) + vim.keymap.set("n", "b", ":Telescope buffers", { noremap = true, silent = true }) + vim.keymap.set("n", "o", ":Telescope oldfiles", { noremap = true, silent = true }) + vim.keymap.set("n", "t", ":Telescope tags", { noremap = true, silent = true }) + vim.keymap.set("n", ":", ":Telescope commands", { noremap = true, silent = true }) + vim.keymap.set("n", "d", ":Telescope git_status", { noremap = true, silent = true }) + vim.keymap.set("n", "", ":Telescope resume", { noremap = true, silent = true }) + end, + }, + + -- Persistent terminal that can be toggled with a keybinding + { + "akinsho/nvim-toggleterm.lua", + tag = "2.3.0", + keys = "", + opts = { + size = 20, + hide_numbers = true, + direction = 'horizontal', + open_mapping = [[]], + shade_terminals = true, + shading_factor = 2, + shell = 'fish' + } + }, + + -- Run code with a keybinding + { + "CRAG666/code_runner.nvim", + opts = { + mode = "toggleterm", + filetype = { + python = "python", + javascript = "node", + typescript = "node", + c = "gcc -o main % && ./main", + }, + }, + init = function() + vim.keymap.set("n", "", ":RunCode", { noremap = true }) + end, + }, + + -- Live Markdown preview in browser + { + "iamcco/markdown-preview.nvim", + build = "cd app && npm install", + ft = "markdown", + init = function() + vim.g.mkdp_auto_close = 0 + end, + }, + + -- Git integration - show modified lines next to line numbers + { + "lewis6991/gitsigns.nvim", + config = function() + require("gitsigns").setup() + require("scrollbar.handlers.gitsigns").setup() + end, + }, + + -- Tool for resolving Git merge conflicts + { + "akinsho/git-conflict.nvim", + tag = "v1.0.0", + config = true, + }, + + -- VSCode-like scrollbar with Git and diagnostic markers + { + "petertriho/nvim-scrollbar", + opts = { + marks = { + Search = { color = "#ff9e64" }, + Error = { color = "#db4b4b" }, + Warn = { color = "#e0af68" }, + Info = { color = "#0db9d7" }, + Hint = { color = "#1abc9c" }, + Misc = { color = "#9d7cd8" }, + GitAdd = { color = "#9ece6a" }, + GitChange = { color = "#e0af68" }, + GitDelete = { color = "#914c54" }, + } + } + }, + + -- Smooth scrolling + { + "karb94/neoscroll.nvim", + opts = { + easing_function = "sine", + } + }, +})