From e6fed655e18343e6e399e8198346466effe8c3a8 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Thu, 18 Mar 2021 22:19:57 +0100 Subject: Fix nvim lua scripts --- .config/nvim/init.lua | 14 +- .config/nvim/lua/_bufferline/init.lua | 2 +- .config/nvim/lua/_comment/init.lua | 3 + .config/nvim/lua/_compe/init.lua | 5 + .config/nvim/lua/_gitsigns/init.lua | 12 -- .config/nvim/lua/_goyo/init.vim | 2 - .config/nvim/lua/_hop/init.lua | 4 +- .config/nvim/lua/_illuminate/init.lua | 1 + .config/nvim/lua/_kommentary/init.lua | 6 - .config/nvim/lua/_lsp/bash-ls.lua | 2 +- .config/nvim/lua/_lsp/docker-ls.lua | 2 +- .config/nvim/lua/_lsp/general.lua | 15 -- .config/nvim/lua/_lsp/init.lua | 59 ++++++- .config/nvim/lua/_lsp/json-ls.lua | 1 + .config/nvim/lua/_lsp/lua-ls.lua | 20 ++- .config/nvim/lua/_lsp/python-ls.lua | 4 +- .config/nvim/lua/_lsp/vim-ls.lua | 2 + .config/nvim/lua/_lsp/vim.lua | 2 - .config/nvim/lua/_lsp/wrapper.lua | 129 --------------- .config/nvim/lua/_lsp/yaml-ls.lua | 4 +- .config/nvim/lua/_matchup/init.lua | 1 + .config/nvim/lua/_nvimtree/init.lua | 23 +++ .config/nvim/lua/_telescope/init.lua | 16 +- .config/nvim/lua/_treesitter/init.lua | 13 +- .config/nvim/lua/_utils/init.lua | 204 ++++++++++++++++++++++++ .config/nvim/lua/_vim-bbye/init.lua | 1 + .config/nvim/lua/_vim-bbye/init.vim | 1 - .config/nvim/lua/_whichkey/init.vim | 236 ---------------------------- .config/nvim/lua/plugins.lua | 25 +-- .config/nvim/vim-script/_goyo/init.vim | 2 + .config/nvim/vim-script/_limelight/init.vim | 23 +++ .config/nvim/vim-script/_nvimtree/init.vim | 19 +++ .config/nvim/vim-script/_whichkey/init.vim | 236 ++++++++++++++++++++++++++++ 33 files changed, 637 insertions(+), 452 deletions(-) create mode 100644 .config/nvim/lua/_comment/init.lua delete mode 100644 .config/nvim/lua/_goyo/init.vim create mode 100644 .config/nvim/lua/_illuminate/init.lua delete mode 100644 .config/nvim/lua/_kommentary/init.lua delete mode 100644 .config/nvim/lua/_lsp/general.lua create mode 100644 .config/nvim/lua/_lsp/vim-ls.lua delete mode 100644 .config/nvim/lua/_lsp/vim.lua delete mode 100644 .config/nvim/lua/_lsp/wrapper.lua create mode 100644 .config/nvim/lua/_matchup/init.lua create mode 100644 .config/nvim/lua/_utils/init.lua create mode 100644 .config/nvim/lua/_vim-bbye/init.lua delete mode 100644 .config/nvim/lua/_vim-bbye/init.vim delete mode 100644 .config/nvim/lua/_whichkey/init.vim create mode 100644 .config/nvim/vim-script/_goyo/init.vim create mode 100644 .config/nvim/vim-script/_limelight/init.vim create mode 100644 .config/nvim/vim-script/_nvimtree/init.vim create mode 100644 .config/nvim/vim-script/_whichkey/init.vim (limited to '.config/nvim') diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 4ee361e..45826ca 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -3,6 +3,7 @@ require('plugins') require('mappings') require('settings') require('colorscheme') +require('_utils') -- Plugins require('_compe') @@ -10,11 +11,13 @@ require('_telescope') require('_autopairs') require('_closetag') require('_colorizer') +require('_comment') require('_floaterm') require('_gitblame') require('_gitsigns') require('_hop') -require('_kommentary') +require('_illuminate') +require('_matchup') -- require('_limeligth') require('_neogit') require('_nvimtree') @@ -23,6 +26,7 @@ require('_rnvimr') require('_startify') -- require('_treesitter') require('_vim-rooter') +require('_vim-bbye') -- bufferline and statusline require('_galaxyline') @@ -30,17 +34,17 @@ require('_bufferline') -- Load vim scripts -- Which Key (Hope to replace with Lua plugin someday) -vim.cmd('source ~/.config/nvim/lua/_goyo/init.vim') -vim.cmd('source ~/.config/nvim/lua/_vim-bbye/init.vim') -vim.cmd('source ~/.config/nvim/lua/_whichkey/init.vim') +vim.cmd('source ~/.config/nvim/vim-script/_goyo/init.vim') +vim.cmd('source ~/.config/nvim/vim-script/_limelight/init.vim') +vim.cmd('source ~/.config/nvim/vim-script/_whichkey/init.vim') -- LSP require('_lspkind') require('_lsp') -require('utils') require('_lsp.bash-ls') require('_lsp.docker-ls') require('_lsp.lua-ls') require('_lsp.json-ls') +require('_lsp.vim-ls') require('_lsp.python-ls') require('_lsp.yaml-ls') diff --git a/.config/nvim/lua/_bufferline/init.lua b/.config/nvim/lua/_bufferline/init.lua index ab7ecae..c3bd69a 100644 --- a/.config/nvim/lua/_bufferline/init.lua +++ b/.config/nvim/lua/_bufferline/init.lua @@ -13,7 +13,7 @@ require'bufferline'.setup{ max_prefix_length = 15, -- prefix used when a buffer is deduplicated tab_size = 18, diagnostics = "nvim_lsp", - show_buffer_close_icons = true, + show_buffer_close_icons = false, show_tab_indicators = true, persist_buffer_sort = true, -- whether or not custom sorted buffers should persist -- can also be a table containing 2 custom separators diff --git a/.config/nvim/lua/_comment/init.lua b/.config/nvim/lua/_comment/init.lua new file mode 100644 index 0000000..df79438 --- /dev/null +++ b/.config/nvim/lua/_comment/init.lua @@ -0,0 +1,3 @@ +require('nvim_comment').setup() +vim.api.nvim_set_keymap("n", "/", ":CommentToggle", {noremap=true, silent = true}) +vim.api.nvim_set_keymap("v", "/", ":CommentToggle", {noremap=true, silent = true}) diff --git a/.config/nvim/lua/_compe/init.lua b/.config/nvim/lua/_compe/init.lua index d269be4..75fa9b5 100644 --- a/.config/nvim/lua/_compe/init.lua +++ b/.config/nvim/lua/_compe/init.lua @@ -1,3 +1,5 @@ +vim.o.completeopt = "menuone,noselect" + require'compe'.setup { enabled = true; autocomplete = true; @@ -27,6 +29,9 @@ require'compe'.setup { } + + + local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end diff --git a/.config/nvim/lua/_gitsigns/init.lua b/.config/nvim/lua/_gitsigns/init.lua index b435be7..c19a5d0 100644 --- a/.config/nvim/lua/_gitsigns/init.lua +++ b/.config/nvim/lua/_gitsigns/init.lua @@ -13,18 +13,6 @@ require('gitsigns').setup { -- Default keymap options noremap = true, buffer = true, - - --[[ ['n ]c'] = { expr = true, "&diff ? ']c' : 'lua require\"gitsigns\".next_hunk()'"}, - ['n [c'] = { expr = true, "&diff ? '[c' : 'lua require\"gitsigns\".prev_hunk()'"}, - ['n hs'] = 'lua require"gitsigns".stage_hunk()', - ['n hu'] = 'lua require"gitsigns".undo_stage_hunk()', - ['n hr'] = 'lua require"gitsigns".reset_hunk()', - ['n hp'] = 'lua require"gitsigns".preview_hunk()', - ['n hb'] = 'lua require"gitsigns".blame_line()', ]] - - -- Text objects - --[[ ['o ih'] = ':lua require"gitsigns".text_object()', - ['x ih'] = ':lua require"gitsigns".text_object()' ]] }, watch_index = { interval = 1000 diff --git a/.config/nvim/lua/_goyo/init.vim b/.config/nvim/lua/_goyo/init.vim deleted file mode 100644 index f617194..0000000 --- a/.config/nvim/lua/_goyo/init.vim +++ /dev/null @@ -1,2 +0,0 @@ -autocmd! User GoyoEnter Limelight lua require('galaxyline').disable_galaxyline() -autocmd! User GoyoLeave Limelight! lua require('galaxyline').galaxyline_augroup() diff --git a/.config/nvim/lua/_hop/init.lua b/.config/nvim/lua/_hop/init.lua index f7dd27d..acd4cd7 100644 --- a/.config/nvim/lua/_hop/init.lua +++ b/.config/nvim/lua/_hop/init.lua @@ -1,2 +1,2 @@ -vim.api.nvim_set_keymap('n', 's', ":HopChar2", {}) -vim.api.nvim_set_keymap('n', 'S', ":HopWord", {}) +vim.api.nvim_set_keymap('n', 's', ":HopChar2", {silent = true}) +vim.api.nvim_set_keymap('n', 'S', ":HopWord", {silent = true}) diff --git a/.config/nvim/lua/_illuminate/init.lua b/.config/nvim/lua/_illuminate/init.lua new file mode 100644 index 0000000..5588aab --- /dev/null +++ b/.config/nvim/lua/_illuminate/init.lua @@ -0,0 +1 @@ +vim.g.Illuminate_ftblacklist = {'NvimTree'} diff --git a/.config/nvim/lua/_kommentary/init.lua b/.config/nvim/lua/_kommentary/init.lua deleted file mode 100644 index 350e1ac..0000000 --- a/.config/nvim/lua/_kommentary/init.lua +++ /dev/null @@ -1,6 +0,0 @@ -vim.g.kommentary_create_default_mappings = false -vim.api.nvim_set_keymap("n", "gc", "kommentary_line_default", {}) -vim.api.nvim_set_keymap("v", "gc", "kommentary_visual_default", {}) -require('kommentary.config').configure_language("default", { - prefer_single_line_comments = true, -}) diff --git a/.config/nvim/lua/_lsp/bash-ls.lua b/.config/nvim/lua/_lsp/bash-ls.lua index 8be0383..7a12dc0 100644 --- a/.config/nvim/lua/_lsp/bash-ls.lua +++ b/.config/nvim/lua/_lsp/bash-ls.lua @@ -1,2 +1,2 @@ -- npm i -g bash-language-server -require'lspconfig'.bashls.setup{} +require'lspconfig'.bashls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/docker-ls.lua b/.config/nvim/lua/_lsp/docker-ls.lua index ad6e220..878aa86 100644 --- a/.config/nvim/lua/_lsp/docker-ls.lua +++ b/.config/nvim/lua/_lsp/docker-ls.lua @@ -1,2 +1,2 @@ -- npm install -g dockerfile-language-server-nodejs -require'lspconfig'.dockerls.setup{} +require'lspconfig'.dockerls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/general.lua b/.config/nvim/lua/_lsp/general.lua deleted file mode 100644 index fa28dbc..0000000 --- a/.config/nvim/lua/_lsp/general.lua +++ /dev/null @@ -1,15 +0,0 @@ -require"lspconfig".efm.setup { - init_options = {documentFormatting = true}, - filetypes = {"lua"}, - settings = { - rootMarkers = {".git/"}, - languages = { - lua = { - { - formatCommand = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb", - formatStdin = true - } - } - } - } -} diff --git a/.config/nvim/lua/_lsp/init.lua b/.config/nvim/lua/_lsp/init.lua index 4515e7c..12ce36a 100644 --- a/.config/nvim/lua/_lsp/init.lua +++ b/.config/nvim/lua/_lsp/init.lua @@ -1,8 +1,24 @@ ---TODO figure out why this don't work -vim.fn.sign_define("LspDiagnosticsSignError", {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"}) -vim.fn.sign_define("LspDiagnosticsSignWarning", {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}) -vim.fn.sign_define("LspDiagnosticsSignInformation", {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}) -vim.fn.sign_define("LspDiagnosticsSignHint", {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}) +-- TODO figure out why this don't work +vim.fn.sign_define("LspDiagnosticsSignError", { + texthl = "LspDiagnosticsSignError", + text = "", + numhl = "LspDiagnosticsSignError" +}) +vim.fn.sign_define("LspDiagnosticsSignWarning", { + texthl = "LspDiagnosticsSignWarning", + text = "", + numhl = "LspDiagnosticsSignWarning" +}) +vim.fn.sign_define("LspDiagnosticsSignInformation", { + texthl = "LspDiagnosticsSignInformation", + text = "", + numhl = "LspDiagnosticsSignInformation" +}) +vim.fn.sign_define("LspDiagnosticsSignHint", { + texthl = "LspDiagnosticsSignHint", + text = "", + numhl = "LspDiagnosticsSignHint" +}) vim.cmd('nnoremap gd lua vim.lsp.buf.definition()') vim.cmd('nnoremap gD lua vim.lsp.buf.declaration()') @@ -17,3 +33,36 @@ vim.cmd('nnoremap :Lspsaga diagnostic_jump_next') vim.cmd('nnoremap lua require(\'lspsaga.action\').smart_scroll_with_saga(1)') -- scroll up hover doc vim.cmd('nnoremap lua require(\'lspsaga.action\').smart_scroll_with_saga(-1)') +vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') + +--[[ " autoformat +autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]] +-- Java +-- autocmd FileType java nnoremap ca lua require('jdtls').code_action() + +local lsp_config = {} + +function lsp_config.common_on_attach(client, bufnr) + + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec([[ + hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]], false) + end +end + +-- Use a loop to conveniently both setup defined servers +-- and map buffer local keybindings when the language server attaches +-- local servers = {"pyright", "tsserver"} +-- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end +return lsp_config diff --git a/.config/nvim/lua/_lsp/json-ls.lua b/.config/nvim/lua/_lsp/json-ls.lua index d13fed3..4fbbeff 100644 --- a/.config/nvim/lua/_lsp/json-ls.lua +++ b/.config/nvim/lua/_lsp/json-ls.lua @@ -1,5 +1,6 @@ -- npm install -g vscode-json-languageserver require'lspconfig'.jsonls.setup { + on_attach = require'_lsp'.common_on_attach, commands = { Format = { function() diff --git a/.config/nvim/lua/_lsp/lua-ls.lua b/.config/nvim/lua/_lsp/lua-ls.lua index c04219a..5768e5d 100644 --- a/.config/nvim/lua/_lsp/lua-ls.lua +++ b/.config/nvim/lua/_lsp/lua-ls.lua @@ -1,21 +1,26 @@ --- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) + -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) USER = vim.fn.expand('$USER') local sumneko_root_path = "" local sumneko_binary = "" if vim.fn.has("mac") == 1 then - sumneko_root_path = "/Users/" .. USER .. "/.config/nvim/lua-language-server" - sumneko_binary = "/Users/" .. USER .. "/.config/nvim/lua-language-server/bin/macOS/lua-language-server" + sumneko_root_path = "/Users/" .. USER .. + "/.config/nvim/ls/lua-language-server" + sumneko_binary = "/Users/" .. USER .. + "/.config/nvim/ls/lua-language-server/bin/macOS/lua-language-server" elseif vim.fn.has("unix") == 1 then - sumneko_root_path = "/home/" .. USER .. "/.config/nvim/lua-language-server" - sumneko_binary = "/home/" .. USER .. "/.config/nvim/lua-language-server/bin/Linux/lua-language-server" + sumneko_root_path = "/home/" .. USER .. + "/.config/nvim/ls/lua-language-server" + sumneko_binary = "/home/" .. USER .. + "/.config/nvim/ls/lua-language-server/bin/Linux/lua-language-server" else print("Unsupported system for sumneko") end require'lspconfig'.sumneko_lua.setup { cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, + on_attach = require'_lsp'.common_on_attach, settings = { Lua = { runtime = { @@ -30,7 +35,10 @@ require'lspconfig'.sumneko_lua.setup { }, workspace = { -- Make the server aware of Neovim runtime files - library = {[vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true} + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true + } } } } diff --git a/.config/nvim/lua/_lsp/python-ls.lua b/.config/nvim/lua/_lsp/python-ls.lua index 11eeef9..d07f59b 100644 --- a/.config/nvim/lua/_lsp/python-ls.lua +++ b/.config/nvim/lua/_lsp/python-ls.lua @@ -1,2 +1,4 @@ -- npm i -g pyright -require'lspconfig'.pyright.setup{} +require'lspconfig'.pyright.setup{ + on_attach = require'_lsp'.common_on_attach, +} diff --git a/.config/nvim/lua/_lsp/vim-ls.lua b/.config/nvim/lua/_lsp/vim-ls.lua new file mode 100644 index 0000000..08039a3 --- /dev/null +++ b/.config/nvim/lua/_lsp/vim-ls.lua @@ -0,0 +1,2 @@ +-- npm install -g vim-language-server +require'lspconfig'.vimls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/vim.lua b/.config/nvim/lua/_lsp/vim.lua deleted file mode 100644 index a7555c6..0000000 --- a/.config/nvim/lua/_lsp/vim.lua +++ /dev/null @@ -1,2 +0,0 @@ --- npm install -g vim-language-server -require'lspconfig'.vimls.setup{} diff --git a/.config/nvim/lua/_lsp/wrapper.lua b/.config/nvim/lua/_lsp/wrapper.lua deleted file mode 100644 index 7f3647c..0000000 --- a/.config/nvim/lua/_lsp/wrapper.lua +++ /dev/null @@ -1,129 +0,0 @@ -local lsp_wrapper = {} - --- buf - -function lsp_wrapper.add_to_workspace_folder() - vim.lsp.buf.add_workspace_folder() -end - -function lsp_wrapper.clear_references() - vim.lsp.buf.clear_references() -end - -function lsp_wrapper.code_action() - vim.lsp.buf.code_action() -end - -function lsp_wrapper.declaration() - vim.lsp.buf.declaration() - vim.lsp.buf.clear_references() -end - -function lsp_wrapper.definition() - vim.lsp.buf.definition() - vim.lsp.buf.clear_references() -end - -function lsp_wrapper.document_highlight() - vim.lsp.buf.document_highlight() -end - -function lsp_wrapper.document_symbol() - vim.lsp.buf.document_symbol() -end - -function lsp_wrapper.formatting() - vim.lsp.buf.formatting() -end - -function lsp_wrapper.formatting_sync() - vim.lsp.buf.formatting_sync() -end - -function lsp_wrapper.hover() - vim.lsp.buf.hover() -end - -function lsp_wrapper.implementation() - vim.lsp.buf.implementation() -end - -function lsp_wrapper.incoming_calls() - vim.lsp.buf.incoming_calls() -end - -function lsp_wrapper.list_workspace_folders() - vim.lsp.buf.list_workspace_folders() -end - -function lsp_wrapper.outgoing_calls() - vim.lsp.buf.outgoing_calls() -end - -function lsp_wrapper.range_code_action() - vim.lsp.buf.range_code_action() -end - -function lsp_wrapper.range_formatting() - vim.lsp.buf.range_formatting() -end - -function lsp_wrapper.references() - vim.lsp.buf.references() - vim.lsp.buf.clear_references() -end - -function lsp_wrapper.remove_workspace_folder() - vim.lsp.buf.remove_workspace_folder() -end - -function lsp_wrapper.rename() - vim.lsp.buf.rename() -end - -function lsp_wrapper.signature_help() - vim.lsp.buf.signature_help() -end - -function lsp_wrapper.type_definition() - vim.lsp.buf.type_definition() -end - -function lsp_wrapper.workspace_symbol() - vim.lsp.buf.workspace_symbol() -end - --- diagnostic - -function lsp_wrapper.get_all() - vim.lsp.diagnostic.get_all() -end - -function lsp_wrapper.get_next() - vim.lsp.diagnostic.get_next() -end - -function lsp_wrapper.get_prev() - vim.lsp.diagnostic.get_prev() -end - -function lsp_wrapper.goto_next() - vim.lsp.diagnostic.goto_next() -end - -function lsp_wrapper.goto_prev() - vim.lsp.diagnostic.goto_prev() -end - -function lsp_wrapper.show_line_diagnostics() - vim.lsp.diagnostic.show_line_diagnostics() -end - --- misc - --- :lua print(vim.inspect(vim.lsp.buf_get_clients())) - --- autoformat --- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) - -return lsp_wrapper diff --git a/.config/nvim/lua/_lsp/yaml-ls.lua b/.config/nvim/lua/_lsp/yaml-ls.lua index 904f20e..e611572 100644 --- a/.config/nvim/lua/_lsp/yaml-ls.lua +++ b/.config/nvim/lua/_lsp/yaml-ls.lua @@ -1,2 +1,4 @@ -- npm install -g yaml-language-server -require'lspconfig'.yamlls.setup{} +require'lspconfig'.yamlls.setup{ + -- on_attach = require'lsp'.common_on_attach, +} diff --git a/.config/nvim/lua/_matchup/init.lua b/.config/nvim/lua/_matchup/init.lua new file mode 100644 index 0000000..4494908 --- /dev/null +++ b/.config/nvim/lua/_matchup/init.lua @@ -0,0 +1 @@ +vim.g.matchup_matchparen_offscreen = {} diff --git a/.config/nvim/lua/_nvimtree/init.lua b/.config/nvim/lua/_nvimtree/init.lua index 3803765..997ade6 100644 --- a/.config/nvim/lua/_nvimtree/init.lua +++ b/.config/nvim/lua/_nvimtree/init.lua @@ -1,3 +1,25 @@ +--[[ " +--let g:nvim_tree_auto_ignore_ft = 'startify' "empty by default, don't auto open tree on specific filetypes. +let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.` +let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons). +" let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open +" let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file +let g:nvim_tree_show_icons = { + \ 'git': 1, + \ 'folders': 1, + \ 'files': 1, + \ } +"If 0, do not show the icons for one of 'git' 'folder' and 'files' +"1 by default, notice that if 'files' is 1, it will only display +"if nvim-web-devicons is installed and on your runtimepath ]] +-- vim.g.nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default +vim.g.nvim_tree_disable_netrw = 0 --"1 by default, disables netrw +-- vim.g.nvim_tree_hijack_netrw = 0 --"1 by default, prevents netrw from automatically opening when opening directories (but lets you keep its other utilities) +vim.g.nvim_tree_hide_dotfiles = 1 --0 by default, this option hides files and folders starting with a dot `.` +vim.g.nvim_tree_indent_markers = 1 --"0 by default, this option shows indent markers when folders are open +vim.g.nvim_tree_follow = 1 --"0 by default, this option allows the cursor to be updated when entering a buffer +vim.g.nvim_tree_auto_close = 1 --0 by default, closes the tree when it's the last window +vim.g.nvim_tree_auto_ignore_ft = 'startify' --"empty by default, don't auto open tree on specific filetypes. local tree_cb = require'nvim-tree.config'.nvim_tree_callback vim.g.nvim_tree_bindings = { -- mappings @@ -29,3 +51,4 @@ vim.g.nvim_tree_bindings = { ["-"] = tree_cb("dir_up"), ["q"] = tree_cb("close") } +vim.cmd([[source ~/.config/nvim/vim-script/_nvimtree/init.vim]]) diff --git a/.config/nvim/lua/_telescope/init.lua b/.config/nvim/lua/_telescope/init.lua index 7466cd4..3d6df8e 100644 --- a/.config/nvim/lua/_telescope/init.lua +++ b/.config/nvim/lua/_telescope/init.lua @@ -25,14 +25,9 @@ require('telescope').setup { results_height = 1, results_width = 0.8, border = {}, - borderchars = { - { '─', '│', '─', '│', '┌', '┐', '┘', '└'}, - prompt = {"─", "│", " ", "│", '┌', '┐', "│", "│"}, - results = {"─", "│", "─", "│", "├", "┤", "┘", "└"}, - preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└'}, - }, + borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'}, color_devicons = true, - use_less = true, + use_less = true, set_env = {['COLORTERM'] = 'truecolor'}, -- default = nil, file_previewer = require'telescope.previewers'.vim_buffer_cat.new, grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, @@ -47,6 +42,7 @@ require('telescope').setup { -- To disable a keymap, put [map] = false -- So, to not map "", just put -- [""] = false, + [""] = actions.close, -- Otherwise, just set the mapping to the function that you want it to be. -- [""] = actions.select_horizontal, @@ -60,7 +56,6 @@ require('telescope').setup { n = { [""] = actions.move_selection_next, [""] = actions.move_selection_previous - -- [""] = actions.close, -- [""] = my_cool_custom_action, } } @@ -76,8 +71,3 @@ require('telescope').setup { } } } - -vim.api.nvim_set_keymap('n', 'ff', 'lua require("telescope.builtin").find_files()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'fg', 'lua require("telescope.builtin").live_grep()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'fb', 'lua require("telescope.builtin").buffers()', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', 'fh', 'lua require("telescope.builtin").help_tags()', { noremap = true, silent = true }) diff --git a/.config/nvim/lua/_treesitter/init.lua b/.config/nvim/lua/_treesitter/init.lua index d202a9f..2b61051 100644 --- a/.config/nvim/lua/_treesitter/init.lua +++ b/.config/nvim/lua/_treesitter/init.lua @@ -3,13 +3,18 @@ require'nvim-treesitter.configs'.setup { highlight = { enable = true, -- false will disable the whole extension }, -} - -require "nvim-treesitter.configs".setup { playground = { enable = true, disable = {}, updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code persist_queries = false -- Whether the query persists across vim sessions - } + }, + rainbow = { + enable = false + }, + refactor = { + highlight_definitions = { + enable = false + } + } } diff --git a/.config/nvim/lua/_utils/init.lua b/.config/nvim/lua/_utils/init.lua new file mode 100644 index 0000000..bed87a3 --- /dev/null +++ b/.config/nvim/lua/_utils/init.lua @@ -0,0 +1,204 @@ +local _utils = {} + +function _utils.define_augroups(definitions) -- {{{1 + -- Create autocommand groups based on the passed definitions + -- + -- The key will be the name of the group, and each definition + -- within the group should have: + -- 1. Trigger + -- 2. Pattern + -- 3. Text + -- just like how they would normally be defined from Vim itself + for group_name, definition in pairs(definitions) do + vim.cmd('augroup ' .. group_name) + vim.cmd('autocmd!') + + for _, def in pairs(definition) do + local command = table.concat(vim.tbl_flatten {'autocmd', def}, ' ') + vim.cmd(command) + end + + vim.cmd('augroup END') + end +end +_utils.define_augroups({ + _general_settings = { + { + 'TextYankPost', '*', + 'lua require(\'vim.highlight\').on_yank({higroup = \'QuickScopePrimary\', timeout = 200})' + }, + {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, + {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, + {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}, + -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'}, + -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'}, + }, + numbertoggle = { + {'BufEnter,FocusGained,InsertLeave', '*', 'set relativenumber'}, + {'BufLeave,FocusLost,InsertEnter', '*', 'set norelativenumber'}, + } +}) + +-- Add this to lightbulb, java makes this annoying tho +-- autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb() + +-- lsp + +function _utils.add_to_workspace_folder() + vim.lsp.buf.add_workspace_folder() + +end + +function _utils.clear_references() + vim.lsp.buf.clear_references() +end + +function _utils.code_action() + vim.lsp.buf.code_action() +end + +function _utils.declaration() + vim.lsp.buf.declaration() + vim.lsp.buf.clear_references() +end + +function _utils.definition() + vim.lsp.buf.definition() + vim.lsp.buf.clear_references() +end + +function _utils.document_highlight() + vim.lsp.buf.document_highlight() +end + +function _utils.document_symbol() + vim.lsp.buf.document_symbol() +end + +function _utils.formatting() + vim.lsp.buf.formatting() +end + +function _utils.formatting_sync() + vim.lsp.buf.formatting_sync() +end + +function _utils.hover() + vim.lsp.buf.hover() +end + +function _utils.implementation() + vim.lsp.buf.implementation() +end + +function _utils.incoming_calls() + vim.lsp.buf.incoming_calls() +end + +function _utils.list_workspace_folders() + vim.lsp.buf.list_workspace_folders() +end + +function _utils.outgoing_calls() + vim.lsp.buf.outgoing_calls() +end + +function _utils.range_code_action() + vim.lsp.buf.range_code_action() +end + +function _utils.range_formatting() + vim.lsp.buf.range_formatting() +end + +function _utils.references() + vim.lsp.buf.references() + vim.lsp.buf.clear_references() +end + +function _utils.remove_workspace_folder() + vim.lsp.buf.remove_workspace_folder() +end + +function _utils.rename() + vim.lsp.buf.rename() +end + +function _utils.signature_help() + vim.lsp.buf.signature_help() +end + +function _utils.type_definition() + vim.lsp.buf.type_definition() +end + +function _utils.workspace_symbol() + vim.lsp.buf.workspace_symbol() +end + +-- diagnostic + +function _utils.get_all() + vim.lsp.diagnostic.get_all() +end + +function _utils.get_next() + vim.lsp.diagnostic.get_next() +end + +function _utils.get_prev() + vim.lsp.diagnostic.get_prev() +end + +function _utils.goto_next() + vim.lsp.diagnostic.goto_next() +end + +function _utils.goto_prev() + vim.lsp.diagnostic.goto_prev() +end + +function _utils.show_line_diagnostics() + vim.lsp.diagnostic.show_line_diagnostics() +end + +-- git signs + +function _utils.next_hunk() + require('gitsigns').next_hunk() +end + +function _utils.prev_hunk() + require('gitsigns').prev_hunk() +end + +function _utils.stage_hunk() + require('gitsigns').stage_hunk() +end + +function _utils.undo_stage_hunk() + require('gitsigns').undo_stage_hunk() +end + +function _utils.reset_hunk() + require('gitsigns').reset_hunk() +end + +function _utils.reset_buffer() + require('gitsigns').reset_buffer() +end + +function _utils.preview_hunk() + require('gitsigns').preview_hunk() +end + +function _utils.blame_line() + require('gitsigns').blame_line() +end + +-- misc + +-- autoformat +-- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) + +return _utils diff --git a/.config/nvim/lua/_vim-bbye/init.lua b/.config/nvim/lua/_vim-bbye/init.lua new file mode 100644 index 0000000..77b4c39 --- /dev/null +++ b/.config/nvim/lua/_vim-bbye/init.lua @@ -0,0 +1 @@ +vim.api.nvim_set_keymap('n', 'q', ':Bdelete', { noremap = true, silent = true }) diff --git a/.config/nvim/lua/_vim-bbye/init.vim b/.config/nvim/lua/_vim-bbye/init.vim deleted file mode 100644 index 10ee440..0000000 --- a/.config/nvim/lua/_vim-bbye/init.vim +++ /dev/null @@ -1 +0,0 @@ -nnoremap q :Bdelete diff --git a/.config/nvim/lua/_whichkey/init.vim b/.config/nvim/lua/_whichkey/init.vim deleted file mode 100644 index c8fe9e4..0000000 --- a/.config/nvim/lua/_whichkey/init.vim +++ /dev/null @@ -1,236 +0,0 @@ -" Leader Key Maps - -" Timeout -let g:which_key_timeout = 100 - -let g:which_key_display_names = {'': '↵', '': '⇆'} - -" Map leader to which_key -nnoremap :silent :silent WhichKey '' -vnoremap :silent :silent WhichKeyVisual '' - -let g:which_key_map = {} -let g:which_key_sep = '→' - -" Not a fan of floating windows for this -let g:which_key_use_floating_win = 0 -let g:which_key_max_size = 0 - -" Hide status line -autocmd! FileType which_key -autocmd FileType which_key set laststatus=0 noshowmode noruler - \| autocmd BufLeave set laststatus=2 noshowmode ruler - - -" Single mappings -" let g:which_key_map['/'] = [ ':call Comment()' , 'comment' ] -" let g:which_key_map['/'] = { 'name' : 'comment' } -let g:which_key_map['/'] = 'which_key_ignore' -let g:which_key_map['?'] = [ ':NvimTreeFindFile' , 'find current file' ] -let g:which_key_map['e'] = [ ':NvimTreeToggle' , 'explorer' ] -let g:which_key_map['h'] = [ 's' , 'split below'] -let g:which_key_map['n'] = [ ':let @/ = ""' , 'no highlight' ] -let g:which_key_map['r'] = [ ':RnvimrToggle' , 'ranger' ] -" TODO create entire treesitter section -let g:which_key_map['T'] = [ ':TSHighlightCapturesUnderCursor' , 'treesitter highlight' ] -let g:which_key_map['v'] = [ 'v' , 'split right'] -" Add Zen mode, play nice with status line -let g:which_key_map['z'] = [ 'Goyo' , 'zen' ] - -" Group mappings - -" a is for actions -let g:which_key_map.a = { - \ 'name' : '+actions' , - \ 'h' : [':let @/ = ""' , 'remove search highlight'], - \ 'l' : [':Bracey' , 'start live server'], - \ 'L' : [':BraceyStop' , 'stop live server'], - \ 'm' : [':MarkdownPreview' , 'markdown preview'], - \ 'M' : [':MarkdownPreviewStop' , 'markdown preview stop'], - \ 'n' : [':set nonumber!' , 'line-numbers'], - \ 's' : [':s/\%V\(.*\)\%V/"\1"/' , 'surround'], - \ 'r' : [':set norelativenumber!' , 'relative line nums'], - \ 't' : [':FloatermToggle' , 'terminal'], - \ 'v' : [':Codi' , 'virtual repl on'], - \ 'V' : [':Codi!' , 'virtual repl off'], - \ 'w' : [':StripWhitespace' , 'strip whitespace'], - \ } - -" b is for buffer -" let g:which_key_map.b = { -" \ 'name' : '+buffer' , -" \ '>' : [':BufferMoveNext' , 'move next'], -" \ '<' : [':BufferMovePrevious' , 'move prev'], -" \ 'b' : [':BufferPick' , 'pick buffer'], -" \ 'd' : [':Bdelete' , 'delete-buffer'], -" \ 'n' : ['bnext' , 'next-buffer'], -" \ 'p' : ['bprevious' , 'previous-buffer'], -" \ '?' : ['Buffers' , 'fzf-buffer'], -" \ } - -" d is for debug -" let g:which_key_map.d = { -" \ 'name' : '+debug' , -" \ 'b' : ['VimspectorToggleBreakpoint' , 'breakpoint'], -" \ 'B' : ['VimspectorToggleConditionalBreakpoint' , 'conditional breakpoint'], -" \ 'c' : ['VimspectorRunToCursor' , 'run to cursor'], -" \ 'd' : ['VimspectorContinue' , 'continue'], -" \ 'f' : ['VimspectorAddFunctionBreakpoint' , 'function breakpoint'], -" \ 'm' : [':MaximizerToggle' , 'maximize window'], -" \ 'o' : ['VimspectorStepOver' , 'step over'], -" \ 'O' : ['VimspectorStepOut' , 'step out'], -" \ 'i' : ['VimspectorStepInto' , 'step into'], -" \ 'p' : ['VimspectorPause' , 'pause'], -" \ 'r' : ['VimspectorRestart' , 'restart'], -" \ 's' : ['VimspectorStop' , 'stop'], -" \ } - -" F is for fold -let g:which_key_map.F = { - \ 'name': '+fold', - \ 'O' : [':set foldlevel=20', 'open all'], - \ 'C' : [':set foldlevel=0', 'close all'], - \ 'c' : [':foldclose', 'close'], - \ 'o' : [':foldopen', 'open'], - \ '1' : [':set foldlevel=1', 'level1'], - \ '2' : [':set foldlevel=2', 'level2'], - \ '3' : [':set foldlevel=3', 'level3'], - \ '4' : [':set foldlevel=4', 'level4'], - \ '5' : [':set foldlevel=5', 'level5'], - \ '6' : [':set foldlevel=6', 'level6'] - \ } - -" s is for search powered by telescope -let g:which_key_map.s = { - \ 'name' : '+search' , - \ '.' : [':Telescope filetypes' , 'filetypes'], - \ ';' : [':Telescope commands' , 'commands'], - \ 'a' : [':Telescope lsp_code_actions' , 'code_actions'], - \ 'A' : [':Telescope builtin' , 'all'], - \ 'b' : [':Telescope buffers' , 'buffers'], - \ 'B' : [':Telescope git_branches' , 'git branches'], - \ 'd' : [':Telescope lsp_document_diagnostics' , 'document_diagnostics'], - \ 'D' : [':Telescope lsp_workspace_diagnostics' , 'workspace_diagnostics'], - \ 'c' : [':Telescope git_commits' , 'git_commits'], - \ 'C' : [':Telescope git_bcommits' , 'git_bcommits'], - \ 'f' : [':Telescope find_files' , 'files'], - \ 'F' : [':Telescope git_files' , 'git_files'], - \ 'g' : [':Telescope tags' , 'tags'], - \ 'G' : [':Telescope current_buffer_tags' , 'buffer_tags'], - \ 'h' : [':Telescope command_history' , 'history'], - \ 'H' : [':Telescope help_tags' , 'help_tags'], - \ 'i' : [':Telescope media_files' , 'media files'], - \ 'k' : [':Telescope keymaps' , 'keymaps'], - \ 'l' : [':Telescope loclist' , 'loclist'], - \ 'm' : [':Telescope marks' , 'marks'], - \ 'M' : [':Telescope man_pages' , 'man_pages'], - \ 'o' : [':Telescope vim_options' , 'vim_options'], - \ 'O' : [':Telescope oldfiles' , 'oldfiles'], - \ 'p' : [':Telescope fd' , 'fd'], - \ 'P' : [':Telescope spell_suggest' , 'spell_suggest'], - \ 's' : [':Telescope git_status' , 'git_status'], - \ 'S' : [':Telescope grep_string' , 'grep_string'], - \ 't' : [':Telescope live_grep' , 'text'], - \ 'y' : [':Telescope symbols' , 'symbols'], - \ 'Y' : [':Telescope lsp_workspace_symbols' , 'lsp_workspace_symbols'], - \ 'r' : [':Telescope registers' , 'registers'], - \ 'R' : [':Telescope reloader' , 'reloader'], - \ 'w' : [':Telescope file_browser' , 'buf_fuz_find'], - \ 'u' : [':Telescope colorscheme' , 'colorschemes'], - \ 'z' : [':Telescope current_buffer_fuzzy_find' , 'buf_fuz_find'], - \ } - -let g:which_key_map.S = { - \ 'name' : '+Session' , - \ 'c' : [':SClose' , 'Close Session'] , - \ 'd' : [':SDelete' , 'Delete Session'] , - \ 'l' : [':SLoad' , 'Load Session'] , - \ 's' : [':Startify' , 'Start Page'] , - \ 'S' : [':SSave' , 'Save Session'] , - \ } - -" g is for git -" let g:which_key_map.g = { -" \ 'name' : '+git' , -" \ 'a' : [':Git add .' , 'add all'], -" \ 'A' : [':CocCommand fzf-preview.GitStatus' , 'actions'], -" \ 'b' : [':Git blame' , 'blame'], -" \ 'B' : [':GBrowse' , 'browse'], -" \ 'c' : [':Git commit' , 'commit'], -" \ 'd' : [':Git diff' , 'diff'], -" \ 'D' : [':Gdiffsplit' , 'diff split'], -" \ 'g' : [':GGrep' , 'git grep'], -" \ 'G' : [':Gstatus' , 'status'], -" \ 'h' : [':GitGutterLineHighlightsToggle' , 'highlight hunks'], -" \ 'H' : ['(GitGutterPreviewHunk)' , 'preview hunk'], -" \ 'i' : [':Gist -b' , 'post gist'], -" \ 'j' : ['(GitGutterNextHunk)' , 'next hunk'], -" \ 'k' : ['(GitGutterPrevHunk)' , 'prev hunk'], -" \ 'l' : [':Git log' , 'log'], -" \ 'm' : ['(git-messenger)' , 'message'], -" \ 'p' : [':Git push' , 'push'], -" \ 'P' : [':Git pull' , 'pull'], -" \ 'r' : [':GRemove' , 'remove'], -" \ 's' : ['(GitGutterStageHunk)' , 'stage hunk'], -" \ 'S' : [':CocCommand fzf-preview.GitStatus' , 'status'], -" \ 't' : [':GitGutterSignsToggle' , 'toggle signs'], -" \ 'u' : ['(GitGutterUndoHunk)' , 'undo hunk'], -" \ 'v' : [':GV' , 'view commits'], -" \ 'V' : [':GV!' , 'view buffer commits'], -" \ } - " \ 'A' : [':Git add %' , 'add current'], - " \ 'S' : [':!git status' , 'status'], - -" let g:which_key_map.G = { -" \ 'name' : '+gist' , -" \ 'a' : [':Gist -a' , 'post gist anon'], -" \ 'b' : [':Gist -b' , 'post gist browser'], -" \ 'd' : [':Gist -d' , 'delete gist'], -" \ 'e' : [':Gist -e' , 'edit gist'], -" \ 'l' : [':Gist -l' , 'list public gists'], -" \ 's' : [':Gist -ls' , 'list starred gists'], -" \ 'm' : [':Gist -m' , 'post gist all buffers'], -" \ 'p' : [':Gist -P' , 'post public gist '], -" \ 'P' : [':Gist -p' , 'post private gist '], -" \ } - -" l is for language server protocol -let g:which_key_map.l = { - \ 'name' : '+lsp' , - \ 'a' : [':Lspsaga code_action' , 'quickfix'], - \ 'A' : [':Lspsaga range_code_action' , 'selected action'], - \ 'd' : [':Telescope lsp_document_diagnostics' , 'document diagnostics'], - \ 'D' : [':Telescope lsp_workspace_diagnostics', 'workspace diagnostics'], - \ 'f' : [':LspFormatting' , 'format'], - \ 'H' : [':Lspsaga signature_help' , 'signature_help'], - \ 'I' : [':LspInfo' , 'lsp_info'], - \ 'l' : [':Lspsaga lsp_finder' , 'lsp_finder'], - \ 'L' : [':Lspsaga show_line_diagnostics' , 'line_diagnostics'], - \ 'o' : [':Vista!!' , 'outline'], - \ 'p' : [':Lspsaga preview_definition' , 'preview definition'], - \ 'q' : [':Telescope quickfix' , 'quickfix'], - \ 'r' : [':LspRename' , 'rename'], - \ 'T' : [':LspTypeDefinition' , 'type defintion'], - \ 'x' : [':cclose' , 'close quickfix'], - \ 's' : [':Telescope lsp_document_symbols' , 'document symbols'], - \ 'S' : [':Telescope lsp_workspace_symbols' , 'workspace symbols'], - \ } - -" t is for terminal -let g:which_key_map.t = { - \ 'name' : '+terminal' , - \ ';' : [':FloatermNew --wintype=normal --height=6' , 'terminal'], - \ 'f' : [':FloatermNew fzf' , 'fzf'], - \ 'g' : [':FloatermNew lazygit' , 'git'], - \ 'd' : [':FloatermNew lazydocker' , 'docker'], - \ 'n' : [':FloatermNew node' , 'node'], - \ 'N' : [':FloatermNew nnn' , 'nnn'], - \ 'p' : [':FloatermNew python' , 'python'], - \ 'm' : [':FloatermNew lazynpm' , 'npm'], - \ 'r' : [':FloatermNew ranger' , 'ranger'], - \ 't' : [':FloatermToggle' , 'toggle'], - \ 'y' : [':FloatermNew btm' , 'btm'], - \ 'u' : [':FloatermNew ncdu' , 'ncdu'], - \ } - -call which_key#register('', "g:which_key_map") diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 1122ba3..fece949 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -1,14 +1,17 @@ local execute = vim.api.nvim_command local fn = vim.fn -local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' - +local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim' if fn.empty(fn.glob(install_path)) > 0 then - execute('!git clone https://github.com/wbthomason/packer.nvim '..install_path) - execute 'packadd packer.nvim' + execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) + execute 'packadd packer.nvim' end +vim.cmd [[packadd packer.nvim]] + +vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are changes in plugins.lua + return require('packer').startup(function() -- Packer can manage itself as an optional plugin @@ -35,9 +38,9 @@ return require('packer').startup(function() use 'hrsh7th/vim-vsnip-integ' -- Treesitter - -- use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - -- use 'nvim-treesitter/playground' - -- use 'p00f/nvim-ts-rainbow' + use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } + use 'nvim-treesitter/playground' + use 'p00f/nvim-ts-rainbow' -- Icons use 'kyazdani42/nvim-web-devicons' @@ -56,7 +59,6 @@ return require('packer').startup(function() -- Explorer use 'kyazdani42/nvim-tree.lua' - -- Color use 'aktersnurra/githubsy.vim' use 'christianchiarulli/nvcode-color-schemes.vim' @@ -66,6 +68,8 @@ return require('packer').startup(function() use 'TimUntersberger/neogit' use {'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } } use 'f-person/git-blame.nvim' + use 'tpope/vim-fugitive' + use 'tpope/vim-rhubarb' -- Easily Create Gists use 'mattn/vim-gist' @@ -86,10 +90,13 @@ return require('packer').startup(function() use 'turbio/bracey.vim' use 'AndrewRadev/tagalong.vim' use 'alvan/vim-closetag' - use { 'glacambre/firenvim', run = function() vim.fn['firenvim#install'](1) end } use 'liuchengxu/vim-which-key' use 'tpope/vim-sleuth' use 'voldikss/vim-floaterm' + use 'liuchengxu/vista.vim' + use 'terrortylor/nvim-comment' + use 'bfredl/nvim-miniyank' + use 'andymass/vim-matchup' use 'phaazon/hop.nvim' use 'junegunn/goyo.vim' use 'junegunn/limelight.vim' diff --git a/.config/nvim/vim-script/_goyo/init.vim b/.config/nvim/vim-script/_goyo/init.vim new file mode 100644 index 0000000..f617194 --- /dev/null +++ b/.config/nvim/vim-script/_goyo/init.vim @@ -0,0 +1,2 @@ +autocmd! User GoyoEnter Limelight lua require('galaxyline').disable_galaxyline() +autocmd! User GoyoLeave Limelight! lua require('galaxyline').galaxyline_augroup() diff --git a/.config/nvim/vim-script/_limelight/init.vim b/.config/nvim/vim-script/_limelight/init.vim new file mode 100644 index 0000000..4e9bf10 --- /dev/null +++ b/.config/nvim/vim-script/_limelight/init.vim @@ -0,0 +1,23 @@ +" Color name (:help cterm-colors) or ANSI code +let g:limelight_conceal_ctermfg = 'gray' +let g:limelight_conceal_ctermfg = 240 + +" Color name (:help gui-colors) or RGB color +let g:limelight_conceal_guifg = 'DarkGray' +let g:limelight_conceal_guifg = '#777777' + +" Default: 0.5 +let g:limelight_default_coefficient = 0.7 + +" Number of preceding/following paragraphs to include (default: 0) +let g:limelight_paragraph_span = 1 + +" Beginning/end of paragraph +" When there's no empty line between the paragraphs +" and each paragraph starts with indentation +let g:limelight_bop = '^\s' +let g:limelight_eop = '\ze\n^\s' + +" Highlighting priority (default: 10) +" Set it to -1 not to overrule hlsearch +let g:limelight_priority = -1 diff --git a/.config/nvim/vim-script/_nvimtree/init.vim b/.config/nvim/vim-script/_nvimtree/init.vim new file mode 100644 index 0000000..de5634e --- /dev/null +++ b/.config/nvim/vim-script/_nvimtree/init.vim @@ -0,0 +1,19 @@ +" TODO this really should be in the lua section +let g:nvim_tree_icons = { + \ 'default': '', + \ 'symlink': '', + \ 'git': { + \ 'unstaged': "", + \ 'staged': "✓", + \ 'unmerged': "", + \ 'renamed': "➜", + \ 'untracked': "✗" + \ }, + \ 'folder': { + \ 'default': "", + \ 'open': "", + \ 'empty': "", + \ 'empty_open': "", + \ 'symlink': "", + \ } + \ } diff --git a/.config/nvim/vim-script/_whichkey/init.vim b/.config/nvim/vim-script/_whichkey/init.vim new file mode 100644 index 0000000..c8fe9e4 --- /dev/null +++ b/.config/nvim/vim-script/_whichkey/init.vim @@ -0,0 +1,236 @@ +" Leader Key Maps + +" Timeout +let g:which_key_timeout = 100 + +let g:which_key_display_names = {'': '↵', '': '⇆'} + +" Map leader to which_key +nnoremap :silent :silent WhichKey '' +vnoremap :silent :silent WhichKeyVisual '' + +let g:which_key_map = {} +let g:which_key_sep = '→' + +" Not a fan of floating windows for this +let g:which_key_use_floating_win = 0 +let g:which_key_max_size = 0 + +" Hide status line +autocmd! FileType which_key +autocmd FileType which_key set laststatus=0 noshowmode noruler + \| autocmd BufLeave set laststatus=2 noshowmode ruler + + +" Single mappings +" let g:which_key_map['/'] = [ ':call Comment()' , 'comment' ] +" let g:which_key_map['/'] = { 'name' : 'comment' } +let g:which_key_map['/'] = 'which_key_ignore' +let g:which_key_map['?'] = [ ':NvimTreeFindFile' , 'find current file' ] +let g:which_key_map['e'] = [ ':NvimTreeToggle' , 'explorer' ] +let g:which_key_map['h'] = [ 's' , 'split below'] +let g:which_key_map['n'] = [ ':let @/ = ""' , 'no highlight' ] +let g:which_key_map['r'] = [ ':RnvimrToggle' , 'ranger' ] +" TODO create entire treesitter section +let g:which_key_map['T'] = [ ':TSHighlightCapturesUnderCursor' , 'treesitter highlight' ] +let g:which_key_map['v'] = [ 'v' , 'split right'] +" Add Zen mode, play nice with status line +let g:which_key_map['z'] = [ 'Goyo' , 'zen' ] + +" Group mappings + +" a is for actions +let g:which_key_map.a = { + \ 'name' : '+actions' , + \ 'h' : [':let @/ = ""' , 'remove search highlight'], + \ 'l' : [':Bracey' , 'start live server'], + \ 'L' : [':BraceyStop' , 'stop live server'], + \ 'm' : [':MarkdownPreview' , 'markdown preview'], + \ 'M' : [':MarkdownPreviewStop' , 'markdown preview stop'], + \ 'n' : [':set nonumber!' , 'line-numbers'], + \ 's' : [':s/\%V\(.*\)\%V/"\1"/' , 'surround'], + \ 'r' : [':set norelativenumber!' , 'relative line nums'], + \ 't' : [':FloatermToggle' , 'terminal'], + \ 'v' : [':Codi' , 'virtual repl on'], + \ 'V' : [':Codi!' , 'virtual repl off'], + \ 'w' : [':StripWhitespace' , 'strip whitespace'], + \ } + +" b is for buffer +" let g:which_key_map.b = { +" \ 'name' : '+buffer' , +" \ '>' : [':BufferMoveNext' , 'move next'], +" \ '<' : [':BufferMovePrevious' , 'move prev'], +" \ 'b' : [':BufferPick' , 'pick buffer'], +" \ 'd' : [':Bdelete' , 'delete-buffer'], +" \ 'n' : ['bnext' , 'next-buffer'], +" \ 'p' : ['bprevious' , 'previous-buffer'], +" \ '?' : ['Buffers' , 'fzf-buffer'], +" \ } + +" d is for debug +" let g:which_key_map.d = { +" \ 'name' : '+debug' , +" \ 'b' : ['VimspectorToggleBreakpoint' , 'breakpoint'], +" \ 'B' : ['VimspectorToggleConditionalBreakpoint' , 'conditional breakpoint'], +" \ 'c' : ['VimspectorRunToCursor' , 'run to cursor'], +" \ 'd' : ['VimspectorContinue' , 'continue'], +" \ 'f' : ['VimspectorAddFunctionBreakpoint' , 'function breakpoint'], +" \ 'm' : [':MaximizerToggle' , 'maximize window'], +" \ 'o' : ['VimspectorStepOver' , 'step over'], +" \ 'O' : ['VimspectorStepOut' , 'step out'], +" \ 'i' : ['VimspectorStepInto' , 'step into'], +" \ 'p' : ['VimspectorPause' , 'pause'], +" \ 'r' : ['VimspectorRestart' , 'restart'], +" \ 's' : ['VimspectorStop' , 'stop'], +" \ } + +" F is for fold +let g:which_key_map.F = { + \ 'name': '+fold', + \ 'O' : [':set foldlevel=20', 'open all'], + \ 'C' : [':set foldlevel=0', 'close all'], + \ 'c' : [':foldclose', 'close'], + \ 'o' : [':foldopen', 'open'], + \ '1' : [':set foldlevel=1', 'level1'], + \ '2' : [':set foldlevel=2', 'level2'], + \ '3' : [':set foldlevel=3', 'level3'], + \ '4' : [':set foldlevel=4', 'level4'], + \ '5' : [':set foldlevel=5', 'level5'], + \ '6' : [':set foldlevel=6', 'level6'] + \ } + +" s is for search powered by telescope +let g:which_key_map.s = { + \ 'name' : '+search' , + \ '.' : [':Telescope filetypes' , 'filetypes'], + \ ';' : [':Telescope commands' , 'commands'], + \ 'a' : [':Telescope lsp_code_actions' , 'code_actions'], + \ 'A' : [':Telescope builtin' , 'all'], + \ 'b' : [':Telescope buffers' , 'buffers'], + \ 'B' : [':Telescope git_branches' , 'git branches'], + \ 'd' : [':Telescope lsp_document_diagnostics' , 'document_diagnostics'], + \ 'D' : [':Telescope lsp_workspace_diagnostics' , 'workspace_diagnostics'], + \ 'c' : [':Telescope git_commits' , 'git_commits'], + \ 'C' : [':Telescope git_bcommits' , 'git_bcommits'], + \ 'f' : [':Telescope find_files' , 'files'], + \ 'F' : [':Telescope git_files' , 'git_files'], + \ 'g' : [':Telescope tags' , 'tags'], + \ 'G' : [':Telescope current_buffer_tags' , 'buffer_tags'], + \ 'h' : [':Telescope command_history' , 'history'], + \ 'H' : [':Telescope help_tags' , 'help_tags'], + \ 'i' : [':Telescope media_files' , 'media files'], + \ 'k' : [':Telescope keymaps' , 'keymaps'], + \ 'l' : [':Telescope loclist' , 'loclist'], + \ 'm' : [':Telescope marks' , 'marks'], + \ 'M' : [':Telescope man_pages' , 'man_pages'], + \ 'o' : [':Telescope vim_options' , 'vim_options'], + \ 'O' : [':Telescope oldfiles' , 'oldfiles'], + \ 'p' : [':Telescope fd' , 'fd'], + \ 'P' : [':Telescope spell_suggest' , 'spell_suggest'], + \ 's' : [':Telescope git_status' , 'git_status'], + \ 'S' : [':Telescope grep_string' , 'grep_string'], + \ 't' : [':Telescope live_grep' , 'text'], + \ 'y' : [':Telescope symbols' , 'symbols'], + \ 'Y' : [':Telescope lsp_workspace_symbols' , 'lsp_workspace_symbols'], + \ 'r' : [':Telescope registers' , 'registers'], + \ 'R' : [':Telescope reloader' , 'reloader'], + \ 'w' : [':Telescope file_browser' , 'buf_fuz_find'], + \ 'u' : [':Telescope colorscheme' , 'colorschemes'], + \ 'z' : [':Telescope current_buffer_fuzzy_find' , 'buf_fuz_find'], + \ } + +let g:which_key_map.S = { + \ 'name' : '+Session' , + \ 'c' : [':SClose' , 'Close Session'] , + \ 'd' : [':SDelete' , 'Delete Session'] , + \ 'l' : [':SLoad' , 'Load Session'] , + \ 's' : [':Startify' , 'Start Page'] , + \ 'S' : [':SSave' , 'Save Session'] , + \ } + +" g is for git +" let g:which_key_map.g = { +" \ 'name' : '+git' , +" \ 'a' : [':Git add .' , 'add all'], +" \ 'A' : [':CocCommand fzf-preview.GitStatus' , 'actions'], +" \ 'b' : [':Git blame' , 'blame'], +" \ 'B' : [':GBrowse' , 'browse'], +" \ 'c' : [':Git commit' , 'commit'], +" \ 'd' : [':Git diff' , 'diff'], +" \ 'D' : [':Gdiffsplit' , 'diff split'], +" \ 'g' : [':GGrep' , 'git grep'], +" \ 'G' : [':Gstatus' , 'status'], +" \ 'h' : [':GitGutterLineHighlightsToggle' , 'highlight hunks'], +" \ 'H' : ['(GitGutterPreviewHunk)' , 'preview hunk'], +" \ 'i' : [':Gist -b' , 'post gist'], +" \ 'j' : ['(GitGutterNextHunk)' , 'next hunk'], +" \ 'k' : ['(GitGutterPrevHunk)' , 'prev hunk'], +" \ 'l' : [':Git log' , 'log'], +" \ 'm' : ['(git-messenger)' , 'message'], +" \ 'p' : [':Git push' , 'push'], +" \ 'P' : [':Git pull' , 'pull'], +" \ 'r' : [':GRemove' , 'remove'], +" \ 's' : ['(GitGutterStageHunk)' , 'stage hunk'], +" \ 'S' : [':CocCommand fzf-preview.GitStatus' , 'status'], +" \ 't' : [':GitGutterSignsToggle' , 'toggle signs'], +" \ 'u' : ['(GitGutterUndoHunk)' , 'undo hunk'], +" \ 'v' : [':GV' , 'view commits'], +" \ 'V' : [':GV!' , 'view buffer commits'], +" \ } + " \ 'A' : [':Git add %' , 'add current'], + " \ 'S' : [':!git status' , 'status'], + +" let g:which_key_map.G = { +" \ 'name' : '+gist' , +" \ 'a' : [':Gist -a' , 'post gist anon'], +" \ 'b' : [':Gist -b' , 'post gist browser'], +" \ 'd' : [':Gist -d' , 'delete gist'], +" \ 'e' : [':Gist -e' , 'edit gist'], +" \ 'l' : [':Gist -l' , 'list public gists'], +" \ 's' : [':Gist -ls' , 'list starred gists'], +" \ 'm' : [':Gist -m' , 'post gist all buffers'], +" \ 'p' : [':Gist -P' , 'post public gist '], +" \ 'P' : [':Gist -p' , 'post private gist '], +" \ } + +" l is for language server protocol +let g:which_key_map.l = { + \ 'name' : '+lsp' , + \ 'a' : [':Lspsaga code_action' , 'quickfix'], + \ 'A' : [':Lspsaga range_code_action' , 'selected action'], + \ 'd' : [':Telescope lsp_document_diagnostics' , 'document diagnostics'], + \ 'D' : [':Telescope lsp_workspace_diagnostics', 'workspace diagnostics'], + \ 'f' : [':LspFormatting' , 'format'], + \ 'H' : [':Lspsaga signature_help' , 'signature_help'], + \ 'I' : [':LspInfo' , 'lsp_info'], + \ 'l' : [':Lspsaga lsp_finder' , 'lsp_finder'], + \ 'L' : [':Lspsaga show_line_diagnostics' , 'line_diagnostics'], + \ 'o' : [':Vista!!' , 'outline'], + \ 'p' : [':Lspsaga preview_definition' , 'preview definition'], + \ 'q' : [':Telescope quickfix' , 'quickfix'], + \ 'r' : [':LspRename' , 'rename'], + \ 'T' : [':LspTypeDefinition' , 'type defintion'], + \ 'x' : [':cclose' , 'close quickfix'], + \ 's' : [':Telescope lsp_document_symbols' , 'document symbols'], + \ 'S' : [':Telescope lsp_workspace_symbols' , 'workspace symbols'], + \ } + +" t is for terminal +let g:which_key_map.t = { + \ 'name' : '+terminal' , + \ ';' : [':FloatermNew --wintype=normal --height=6' , 'terminal'], + \ 'f' : [':FloatermNew fzf' , 'fzf'], + \ 'g' : [':FloatermNew lazygit' , 'git'], + \ 'd' : [':FloatermNew lazydocker' , 'docker'], + \ 'n' : [':FloatermNew node' , 'node'], + \ 'N' : [':FloatermNew nnn' , 'nnn'], + \ 'p' : [':FloatermNew python' , 'python'], + \ 'm' : [':FloatermNew lazynpm' , 'npm'], + \ 'r' : [':FloatermNew ranger' , 'ranger'], + \ 't' : [':FloatermToggle' , 'toggle'], + \ 'y' : [':FloatermNew btm' , 'btm'], + \ 'u' : [':FloatermNew ncdu' , 'ncdu'], + \ } + +call which_key#register('', "g:which_key_map") -- cgit v1.2.3-70-g09d2