diff options
Diffstat (limited to '.config/nvim/lua')
28 files changed, 348 insertions, 447 deletions
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", "<leader>/", ":CommentToggle<CR>", {noremap=true, silent = true}) +vim.api.nvim_set_keymap("v", "<leader>/", ":CommentToggle<CR>", {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' : '<cmd>lua require\"gitsigns\".next_hunk()<CR>'"}, - ['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns\".prev_hunk()<CR>'"}, - ['n <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>', - ['n <leader>hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>', - ['n <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>', - ['n <leader>hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>', - ['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line()<CR>', ]] - - -- Text objects - --[[ ['o ih'] = ':<C-U>lua require"gitsigns".text_object()<CR>', - ['x ih'] = ':<C-U>lua require"gitsigns".text_object()<CR>' ]] }, 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<cr>", {}) -vim.api.nvim_set_keymap('n', 'S', ":HopWord<cr>", {}) +vim.api.nvim_set_keymap('n', 's', ":HopChar2<cr>", {silent = true}) +vim.api.nvim_set_keymap('n', 'S', ":HopWord<cr>", {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", "<Plug>kommentary_line_default", {}) -vim.api.nvim_set_keymap("v", "gc", "<Plug>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 <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>') vim.cmd('nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>') @@ -17,3 +33,36 @@ vim.cmd('nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>') vim.cmd('nnoremap <silent> <C-f> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(1)<CR>') -- scroll up hover doc vim.cmd('nnoremap <silent> <C-b> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(-1)<CR>') +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 <Cmd>lua require('jdtls').code_action()<CR> + +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! * <buffer> + autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() + autocmd CursorMoved <buffer> 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 "<C-n>", just put -- ["<c-x>"] = false, + ["<esc>"] = actions.close, -- Otherwise, just set the mapping to the function that you want it to be. -- ["<C-i>"] = actions.select_horizontal, @@ -60,7 +56,6 @@ require('telescope').setup { n = { ["<C-j>"] = actions.move_selection_next, ["<C-k>"] = actions.move_selection_previous - -- ["<esc>"] = actions.close, -- ["<C-i>"] = my_cool_custom_action, } } @@ -76,8 +71,3 @@ require('telescope').setup { } } } - -vim.api.nvim_set_keymap('n', '<leader>ff', '<cmd>lua require("telescope.builtin").find_files()<cr>', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '<leader>fg', '<cmd>lua require("telescope.builtin").live_grep()<cr>', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '<leader>fb', '<cmd>lua require("telescope.builtin").buffers()<cr>', { noremap = true, silent = true }) -vim.api.nvim_set_keymap('n', '<leader>fh', '<cmd>lua require("telescope.builtin").help_tags()<cr>', { 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', '<Leader>q', ':Bdelete<CR>', { 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 <Leader>q :Bdelete<CR> 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 = {'<CR>': '↵', '<TAB>': '⇆'} - -" Map leader to which_key -nnoremap <silent> <leader> :silent <c-u> :silent WhichKey '<Space>'<CR> -vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR> - -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 <buffer> 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'] = [ '<C-W>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'] = [ '<C-W>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' : ['<Plug>VimspectorToggleBreakpoint' , 'breakpoint'], -" \ 'B' : ['<Plug>VimspectorToggleConditionalBreakpoint' , 'conditional breakpoint'], -" \ 'c' : ['<Plug>VimspectorRunToCursor' , 'run to cursor'], -" \ 'd' : ['<Plug>VimspectorContinue' , 'continue'], -" \ 'f' : ['<Plug>VimspectorAddFunctionBreakpoint' , 'function breakpoint'], -" \ 'm' : [':MaximizerToggle' , 'maximize window'], -" \ 'o' : ['<Plug>VimspectorStepOver' , 'step over'], -" \ 'O' : ['<Plug>VimspectorStepOut' , 'step out'], -" \ 'i' : ['<Plug>VimspectorStepInto' , 'step into'], -" \ 'p' : ['<Plug>VimspectorPause' , 'pause'], -" \ 'r' : ['<Plug>VimspectorRestart' , 'restart'], -" \ 's' : ['<Plug>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' : ['<Plug>(GitGutterPreviewHunk)' , 'preview hunk'], -" \ 'i' : [':Gist -b' , 'post gist'], -" \ 'j' : ['<Plug>(GitGutterNextHunk)' , 'next hunk'], -" \ 'k' : ['<Plug>(GitGutterPrevHunk)' , 'prev hunk'], -" \ 'l' : [':Git log' , 'log'], -" \ 'm' : ['<Plug>(git-messenger)' , 'message'], -" \ 'p' : [':Git push' , 'push'], -" \ 'P' : [':Git pull' , 'pull'], -" \ 'r' : [':GRemove' , 'remove'], -" \ 's' : ['<Plug>(GitGutterStageHunk)' , 'stage hunk'], -" \ 'S' : [':CocCommand fzf-preview.GitStatus' , 'status'], -" \ 't' : [':GitGutterSignsToggle' , 'toggle signs'], -" \ 'u' : ['<Plug>(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('<Space>', "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' |