summary refs log tree commit diff
path: root/.vim/lua/plugins.lua
diff options
context:
space:
mode:
Diffstat (limited to '.vim/lua/plugins.lua')
-rw-r--r--.vim/lua/plugins.lua487
1 files changed, 396 insertions, 91 deletions
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua
index f5f9a37..cb8bdb1 100644
--- a/.vim/lua/plugins.lua
+++ b/.vim/lua/plugins.lua
@@ -1,14 +1,22 @@
+-- vim: foldenable
 -- load by calling `lua require('plugins')` from your init.vim
 local g = vim.g
 local u = require('utils')
 
--- local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
--- if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
---   vim.fn.system({ 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path })
---   vim.api.nvim_command 'packadd packer.nvim'
--- end
+-- force packer into a system directory
+local sysdata = vim.fn.stdpath('data_dirs')[1]
 
-function disable_distribution_plugins()
+local install_path = sysdata .. '/site/pack/packer/start/packer.nvim'
+if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
+  vim.fn.system({ 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path })
+  vim.api.nvim_command 'packadd packer.nvim'
+end
+
+if not vim.fn.filewritable(vim.fn.stdpath('cache')) == 2 then
+  return
+end
+
+function disable_distribution_plugins() --{{{
   g.loaded_gzip              = 1
   g.loaded_tar               = 1
   g.loaded_tarPlugin         = 1
@@ -27,12 +35,9 @@ function disable_distribution_plugins()
   g.loaded_netrwPlugin       = 1
   g.loaded_netrwSettings     = 1
   g.loaded_netrwFileHandlers = 1
-end
-
--- enable to bootstrap packer from ~/.local/share/nvim/site/pack/packer/opt/packer.nvim
--- vim.cmd [[packadd packer.nvim]]
+end -- }}}
 
-return require'packer'.startup(function()
+return require('packer').startup({function()
   -- disable built-in plugins
   disable_distribution_plugins()
 
@@ -40,119 +45,388 @@ return require'packer'.startup(function()
   use {'wbthomason/packer.nvim'}
 
   -- git status in the sign column
-  use {'mhinz/vim-signify',
-    config = "require('plugins._signify')"
-  }
+  use {'mhinz/vim-signify', -- {{{
+    config = function()
+      local nnoremap = require('astronauta.keymap').nnoremap
+
+      vim.g.signify_sign_change = '~'
+
+      nnoremap { ']h', function() vim.fn['sy#jump#next_hunk'](1) end }
+      nnoremap { '[h', function() vim.fn['sy#jump#prev_hunk'](1) end }
+    end} -- }}}
 
   use {'tpope/vim-commentary'}   -- auto-comment using `gcc`
-  use {'cohama/lexima.vim'}      -- auto-close parens, brackets, etc.
+
+  use {'windwp/nvim-autopairs',
+    config = function()
+      require('nvim-autopairs').setup()
+    end}
+
   use {'tpope/vim-surround'}     -- edit surroundings in pairs
-  -- use {'neomake/neomake'}        -- async job runner
-  use {'sbdchd/neoformat'}       -- async code formatter
+
   use {'justinmk/vim-dirvish'}   -- folder browser
-  use {'justinmk/vim-sneak',
-    config = "vim.g['sneak#label'] = true"
-  }
+
+  use {'ggandor/lightspeed.nvim'}
+
+  use {'jose-elias-alvarez/null-ls.nvim', -- {{{
+    requires = {'nvim-lua/plenary.nvim'},
+    config = function()
+      local nls = require('null-ls')
+      nls.config {
+        sources = {
+          nls.builtins.formatting.clang_format, -- c*
+          nls.builtins.formatting.gofumpt, -- go
+          nls.builtins.formatting.json_tool, -- json
+          nls.builtins.formatting.rustfmt, -- rust
+          nls.builtins.formatting.shfmt, -- *sh
+          nls.builtins.formatting.yapf, -- python
+          nls.builtins.diagnostics.shellcheck, -- *sh
+        }
+      }
+
+      require('lspconfig')['null-ls'].setup {
+        on_attach = require('lsp').my_attach
+      }
+    end} -- }}}
 
   use {'neovim/nvim-lspconfig',
-    requires = {
-      {'kosayoda/nvim-lightbulb', config = "require('plugins._lightbulb')"},
-    },
-    config = "require('plugins._lsp')"
-  }
+    requires = {'~/devel/projects/spinner.nvim'},
+    config = function()
+      require('lsp').setup()
+    end}
+
+  use {'kosayoda/nvim-lightbulb', -- {{{
+    config = function()
+      require('nvim-lightbulb').update_lightbulb {
+        sign = {
+          enabled = true,
+          priority = 10,
+        },
+        float = {
+          enabled = true,
+          text = '󱉵 ',
+          win_opts = {},
+        },
+        virtual_text = {
+          enabled = false,
+          text = '󱉵 ',
+        },
+        status_text = {
+          enabled = false,
+        }
+      }
+
+      vim.fn.sign_define('LightBulbSign', {text="⚐", texthl="LightBulbVirtualText"})
 
-  use {'nvim-treesitter/nvim-treesitter',
+      require('utils').augroup2 {
+        lightbulb = {
+          {'CursorHold', '*', "lua require('nvim-lightbulb').update_lightbulb()"}
+        }
+      }
+    end} -- }}}
+
+  use {'nvim-treesitter/nvim-treesitter', -- {{{
+    run = ':TSUpdate',
     requires = {
       'nvim-treesitter/completion-treesitter',
       'nvim-treesitter/nvim-treesitter-refactor',
     },
-    config = "require('plugins._treesitter')",
-    run = ':TSUpdate',
-  }
+    config = function()
+      require('nvim-treesitter.configs').setup {
+        ensure_installed = { 
+          "bash",
+          "c",
+          "c_sharp",
+          "css",
+          "dockerfile",
+          "html",
+          "go", "gomod",
+          "javascript",
+          "ledger",
+          "lua",
+          "rust",
+          "typescript",
+        },
+        highlight = {
+          enable = false,
+        },
+        indent = {
+          enable = true,
+        },
+        refactor = {
+          navigation = {
+            enable = true,
+            keymaps = {
+              goto_definition = "<c-]>",
+            },
+          },
+          smart_rename = {
+            enable = true,
+            keymaps = {
+              smart_rename = "grr",
+            },
+          },
+        },
+      }
+    end} -- }}}
 
-  use {'nvim-lua/completion-nvim',
-    requires = {'steelsojka/completion-buffers'},
-    config = "require('plugins._completion')",
-  }
+  use {'hrsh7th/nvim-compe', -- {{{
+    -- requires nvim-autopairs
+    config = function()
+      require('compe').setup {
+        enabled = true,
+        autocomplete = true,
+        preselect = 'enable',
+        documentation = {
+          border = 'single',
+        },
+        source = {
+          path = true,
+          buffer = true,
+          tags = true,
+          nvim_lsp = true,
+          nvim_lua = true,
+          orgmode = true,
+          ultisnips = true,
+        }
+      }
 
-  -- use {'hrsh7th/nvim-compe',
-  --   config = "require('plugins._compe')",
-  -- }
+      vim.cmd [[
+        inoremap <silent><expr> <c-space> compe#complete()
+        inoremap <silent><expr> <c-e>     compe#close('<c-e>')
+      ]]
+
+      require('nvim-autopairs.completion.compe').setup {
+        map_cr = true,
+        map_complete = true,
+      }
+    end} -- }}}
 
-  use {'nvim-telescope/telescope.nvim',
+  use {'nvim-telescope/telescope.nvim', --- {{{
     requires = {
       'nvim-lua/popup.nvim',
       'nvim-lua/plenary.nvim',
       -- telescope plugins:
       'nvim-telescope/telescope-fzf-writer.nvim',
     },
-    config = "require('plugins._telescope')"
-  }
+    config = function()
+      local nnoremap = require('astronauta.keymap').nnoremap
+
+      require('telescope').setup{
+        defaults = {
+          -- initial_mode = 'input',
+          prompt_prefix = '> ',
+          selection_caret = '* ',
+
+          sorting_strategy = 'ascending',
+
+          preview_title = '',
+          layout_strategy = 'bottom_pane',
+          layout_config = {
+            preview_cutoff = 1,
+            height = 20,
+          },
+          border = true,
+          borderchars = {
+            'z',
+            prompt = { '─', ' ', ' ', ' ', '─', '─', ' ', ' ' },
+            results = { ' ' },
+            -- results = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' },
+            preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└'},
+
+            -- "center"
+            -- { '─', '│', '─', '│', '┌', '┐', '┘', '└'},
+            -- prompt = {'─', '│', ' ', '│', '┌', '┐', '│', '│'},
+            -- results = {'─', '│', '─', '│', '├', '┤', '┘', '└'},
+            -- preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└'},
+          },
+
+          file_previewer   = require('telescope.previewers').vim_buffer_cat.new,
+          grep_previewer   = require('telescope.previewers').vim_buffer_vimgrep.new,
+          qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new,
+
+          extensions = {
+            fzf_writer = {
+              use_highlighter = true,
+              minimum_grep_characters = 4,
+              shorten_path = true,
+            }
+          }
+        }
+      }
+
+      nnoremap { ';q', require('telescope.builtin').quickfix }
+      nnoremap { ';c', require('telescope.builtin').loclist }
+
+      nnoremap { ';g', require('telescope').extensions.fzf_writer.staged_grep }
+      nnoremap { ';f', require('telescope.builtin').fd }
+      nnoremap { ';l', require('telescope.builtin').current_buffer_fuzzy_find }
+      nnoremap { ';w', require('telescope.builtin').file_browser }
+      nnoremap { ';b', require('telescope.builtin').buffers }
+      nnoremap { ';t', require('telescope.builtin').tags }
+      nnoremap { ';h', require('telescope.builtin').command_history }
+      nnoremap { ';H', require('telescope.builtin').help_tags }
+      nnoremap { ';c', require('telescope.builtin').commands }
+
+      nnoremap { ';v', function()
+          require('telescope.builtin').find_files({
+            prompt_title = 'vimrc',
+            previewer = false,
+            cwd = vim.fn.stdpath('config'),
+          })
+        end }
+
+      -- LSP stuff
+      nnoremap { ';a', require('telescope.builtin').lsp_code_actions }
+      nnoremap { ';0', require('telescope.builtin').lsp_document_symbols }
+      nnoremap { ';r', require('telescope.builtin').lsp_references }
+    end} -- }}}
 
   -- polyfill for some missing stuff
   use {'tjdevries/astronauta.nvim'}
 
   -- snippets
-  use {'SirVer/ultisnips',
+  use {'SirVer/ultisnips', -- {{{
     requires = {'honza/vim-snippets'},
-    config = "require('plugins._ultisnips')"
-  }
+    config = function()
+      vim.g.UltiSnipsJumpForwardTrigger = "<tab>"
+      vim.g.UltiSnipsJumpBackwardTrigger = "<s-tab>"
+    end} -- }}}
+
+  -- use {'L3MON4D3/LuaSnip',
+  --   config = "require('plugins._ultisnips')",
+  -- }
 
   use {'junegunn/vim-easy-align'}
 
-  use {'editorconfig/editorconfig-vim',
-    config = "require('plugins._editorconfig')"
-  }
-  -- use {'tpope/vim-sleuth'}                -- detect indentation
-  use {'nathanaelkane/vim-indent-guides',
-    disable = true,
-    config = "require('plugins._indent-guides')"
-  }
+  use {'editorconfig/editorconfig-vim', -- {{{
+    config = function()
+      require('utils').augroup2 {
+        editorconfig = {
+          { 'FileType', 'gitcommit', 'let b:EditorConfig_disable = 1' },
+        }
+      }
+    end} -- }}}
 
-  use {'tpope/vim-repeat'}                -- extend '.' to plugins
-  use {'michaeljsmith/vim-indent-object'} -- adds indentation text-objects
-  use {'kshenoy/vim-signature', disable = true}           -- toggle, display and navigate marks
-  use {'norcalli/nvim-colorizer.lua',
-    config = "require('plugins._colorizer')"
-  }
+  use {'lukas-reineke/indent-blankline.nvim',
+    config = function()
+      vim.g.indent_blankline_char = '▏'
+    end}
 
-  use {'rhysd/git-messenger.vim',
-    config = "require('plugins._git-messenger')"
-  }
+  use {'tpope/vim-repeat'} -- extend '.' to plugins
+  use {'michaeljsmith/vim-indent-object'} -- indentation text-objects
+  use {'kshenoy/vim-signature', disable = true} -- toggle, display and navigate marks
+  use {'norcalli/nvim-colorizer.lua', -- {{{
+    config = function()
+      require('colorizer').setup(nil, {
+        name = true;
+        RRGGBB = true;
+        RRGGBBAA = false;
+        rgb_fn = true;
+        hsl_fn = true;
+        mode = 'background';
+      })
+    end} -- }}}
 
-  use {'TimUntersberger/neogit'}
+  use {'rhysd/git-messenger.vim', -- {{{
+    config = function()
+      -- vim.g.git_messenger_include_diff = false
+      vim.g.git_messenger_always_into_popup = true
+      vim.g.git_messenger_close_on_cursor_moved = true
+      vim.g.git_messenger_no_default_mappings = true
+    end} -- }}}
 
+  -- use {'TimUntersberger/neogit',
+  --   config = "require('astronauta.keymap').nnoremap { '<leader>gg', function() require('neogit').open({ kind = 'split' }) end }"
+  -- }
+
+  use {'liuchengxu/vista.vim'}
   use {'rhysd/conflict-marker.vim', disable = true}
-  -- use {'liuchengxu/vista.vim'}            -- sidebar populated by lsp, ctags, etc.
   use {'kassio/neoterm', disable = true}
 
   -- zettelkasten via neuron
-  -- NOTE: needs telescope.nvim and plenary.nvim
-  use {'oberblastmeister/neuron.nvim',
+  use {'oberblastmeister/neuron.nvim', -- {{{
     branch = 'unstable',
     requires = {'nvim-telescope/telescope.nvim'},
-    config = "require('.plugins._neuron')"
-  }
+    config = function()
+      require('neuron').setup {
+        virtual_titles = true,
+        mappings = true,
+        run = nil,
+        neuron_dir = "~/.zk",
+        leader = "gz",
+      }
+
+      vim.cmd [[ command! NeuronServe lua require('neuron').rib {address = "127.0.0.1:8200", verbose = true} ]]
+      vim.cmd [[ command! NeuronZettels lua require('neuron.telescope').find_zettels {insert = false} ]]
+      vim.cmd [[ command! NeuronZettelsInsert lua require('neuron.telescope').find_zettels {insert = true} ]]
+      vim.cmd [[ command! NeuronTags lua require('neuron.telescope').find_tags() ]]
+    end} -- }}}
+
+  use {'kristijanhusak/orgmode.nvim', -- {{{
+    config = function()
+      local nnoremap = require('astronauta.keymap').nnoremap
+
+      require('orgmode').setup {
+        org_agenda_files = {'$HOME/.zk/.orgmode/*.org'},
+        org_default_notes_file = '$HOME/.zk/.orgmode/todo.org',
+      }
+
+      local pickers = require('telescope.pickers')
+      local finders = require('telescope.finders')
+
+      nnoremap { ';o', function()
+          pickers.new(opts, {
+            prompt_title = 'Orgmode',
+            finder = finders.new_table(require('orgmode.config'):get_all_files()),
+          }):find()
+        end }
+
+      vim.cmd [[ command! Orgmode lua require('orgmode').action('agenda.prompt') ]]
+      vim.cmd [[ command! OrgmodeCapture lua require('orgmode').action('capture.refile') ]]
+      vim.cmd [[ command! OrgmodeInsert lua require('orgmode').action('org_mappings.insert_heading_respect_content') ]]
+      vim.cmd [[ command! OrgmodeTodoCycle lua require('orgmode').action('org_mappings.todo_next_state') ]]
+      vim.cmd [[ command! OrgmodeTag lua require('orgmode').action('org_mappings.set_tags') ]]
+      vim.cmd [[ command! OrgmodeArchive lua require('orgmode').action('org_mappings.toggle_archive_tag') ]]
+    end} -- }}}
 
   -- languages
   -- NOTE: these should only be loaded when they are required...
   -- use {'rhysd/vim-grammarous',
   --  ft = {'markdown', 'latex', 'tex'}
   -- }
-  use {'lervag/vimtex',
+  use {'lervag/vimtex', -- {{{
     ft = {'latex', 'tex'},
-    config = "require('plugins._vimtex')"
-  }
-  use {'plasticboy/vim-markdown',
+    config = function()
+      vim.g.tex_flavor = 'latex'
+      vim.g.vimtex_compiler_enabled = 0
+      vim.g.vimtex_compiler_method = 'tectonic'
+      vim.g.vimtex_compiler_tectonic = "{'executable': 'tectonic'}"
+      vim.g.vimtex_view_method = 'zathura'
+      -- vim.g.vimtex_view_zathura_check_libsynctex = false
+      -- vim.g.vimtex_view_use_temp_files = true
+      -- vim.g.vimtex_view_forward_search_on_start = false
+    end} -- }}}
+
+  use {'plasticboy/vim-markdown', -- {{{
     ft = {'markdown'},
-    config = "require('plugins._markdown')"
-  }
-  use {'masukomi/vim-markdown-folding',
-    ft = {'markdown'}
-  }
-  use {'jjo/vim-cue',
-    ft = {'cue'}
-  }
+    config = function()
+      vim.g.vim_markdown_folding_disabled = true
+      vim.g.vim_markdown_math = true
+      vim.g.vim_markdown_frontmatter = true
+      vim.g.vim_markdown_json_frontmatter = true
+      vim.g.vim_markdown_toml_frontmatter = true
+      vim.g.vim_markdown_yaml_frontmatter = true
+      -- vim.g.vim_markdown_folding_level = 2
+      vim.g.vim_markdown_strikethrough = true
+      vim.g.vim_markdown_auto_insert_bullets = true
+      vim.g.vim_markdown_new_list_item_indent = false
+      vim.g.vim_markdown_conceal = true
+      vim.g.vim_markdown_conceal_code_blocks = true
+    end} -- }}}
+
+  use {'masukomi/vim-markdown-folding', ft = {'markdown'}}
+  use {'jjo/vim-cue', ft = {'cue'}}
   use {'gentoo/gentoo-syntax'}
 
   -- multi-language support with lazy loading
@@ -160,22 +434,53 @@ return require'packer'.startup(function()
   g.polyglot_disabled = { 'autoindent' }
   use {'sheerun/vim-polyglot'}
 
-  -- minimal ux
-  use {'junegunn/goyo.vim',
-    cmd = 'Goyo',
-    config = "require('plugins._goyo')"
-  }
-  use {'junegunn/limelight.vim',
-    cmd = 'Limelight',
-    config = "require('plugins._limelight')"
-  }
+  use {'folke/zen-mode.nvim', -- {{{
+    config = function()
+      require('zen-mode').setup {
+        window = {
+          backdrop = 1,
+          width = 0.3,
+          -- height = 1,
+          options = {
+            number = false,
+            list = false,
+          },
+        },
+        plugins = {
+          options = {
+            enabled = true,
+            ruler = false,
+            showcmd = false,
+          },
+          twilight = { enabled = true },
+        }
+      }
+    end} -- }}}
 
-  use {'rktjmp/lush.nvim',}
-    -- config="require('colors')"}
+  use {'folke/twilight.nvim', -- {{{
+    config = function()
+      require('twilight').setup {
+        context = 15,
+        dimming = {
+          alpha = 0.3,
+          color = { 'Normal', '#ffffff' },
+        },
+      }
+    end} -- }}}
 
-  -- vim config debugging
-  use {'dstein64/vim-startuptime', disable = true}
+  use {'mhinz/vim-startify', -- {{{
+    config = function()
+      require('utils').augroup2 {
+        startify = {{ 'FileType', 'startify', [[ IndentBlanklineDisable ]] }}
+      }
+    end} -- }}}
+
+  use {'rktjmp/lush.nvim'}
 
   -- local
   use {'~/devel/upstream/github.com/knsh14/vim-github-link'}
-end)
+
+end,
+config = {
+  package_root = require('packer.util').join_paths(sysdata, 'site', 'pack'),
+}})