diff options
Diffstat (limited to '.config/nvim/plugins')
-rw-r--r-- | .config/nvim/plugins/_install.vim | 45 | ||||
-rw-r--r-- | .config/nvim/plugins/_load.vim | 10 | ||||
-rw-r--r-- | .config/nvim/plugins/aerial.vim | 28 | ||||
-rw-r--r-- | .config/nvim/plugins/comment.vim | 3 | ||||
-rw-r--r-- | .config/nvim/plugins/gitgutter.vim | 2 | ||||
-rw-r--r-- | .config/nvim/plugins/indent_blankline.vim | 11 | ||||
-rw-r--r-- | .config/nvim/plugins/leap.vim | 3 | ||||
-rw-r--r-- | .config/nvim/plugins/lsp.vim | 91 | ||||
-rw-r--r-- | .config/nvim/plugins/markdown_preview.vim | 3 | ||||
-rw-r--r-- | .config/nvim/plugins/nerdtree.vim | 33 | ||||
-rw-r--r-- | .config/nvim/plugins/telescope.vim | 3 | ||||
-rw-r--r-- | .config/nvim/plugins/treesitter.vim | 13 |
12 files changed, 245 insertions, 0 deletions
diff --git a/.config/nvim/plugins/_install.vim b/.config/nvim/plugins/_install.vim new file mode 100644 index 0000000..9bc483c --- /dev/null +++ b/.config/nvim/plugins/_install.vim @@ -0,0 +1,45 @@ +call plug#begin(stdpath('data') . '/plugged') + +Plug 'doums/darcula' + +Plug 'ryanoasis/vim-devicons' +Plug 'nvim-tree/nvim-web-devicons' + +Plug 'preservim/nerdtree' +Plug 'Xuyuanp/nerdtree-git-plugin' + +Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' + +Plug 'airblade/vim-gitgutter' + +Plug 'mg979/vim-xtabline' + +Plug 'ggandor/leap.nvim' + +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + +Plug 'lukas-reineke/indent-blankline.nvim' + +Plug 'tpope/vim-surround' + +Plug 'gpanders/editorconfig.nvim' + +Plug 'iamcco/markdown-preview.nvim', {'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']} +" if install fails do `:call mkdp#util#install() manually` + +Plug 'stevearc/aerial.nvim' +Plug 'numToStr/Comment.nvim' + +Plug 'williamboman/mason.nvim' +Plug 'williamboman/mason-lspconfig.nvim' +Plug 'neovim/nvim-lspconfig' +Plug 'hrsh7th/nvim-cmp' +Plug 'hrsh7th/cmp-nvim-lsp' +Plug 'saadparwaiz1/cmp_luasnip' +Plug 'L3MON4D3/LuaSnip' + +"Plug 'https://gitlab.com/dweipert.de/rclone.nvim' +Plug '~/Projects/rclone.nvim' + +call plug#end() diff --git a/.config/nvim/plugins/_load.vim b/.config/nvim/plugins/_load.vim new file mode 100644 index 0000000..c101014 --- /dev/null +++ b/.config/nvim/plugins/_load.vim @@ -0,0 +1,10 @@ +source ~/.config/nvim/plugins/aerial.vim +source ~/.config/nvim/plugins/comment.vim +source ~/.config/nvim/plugins/gitgutter.vim +source ~/.config/nvim/plugins/indent_blankline.vim +source ~/.config/nvim/plugins/leap.vim +source ~/.config/nvim/plugins/lsp.vim +source ~/.config/nvim/plugins/markdown_preview.vim +source ~/.config/nvim/plugins/nerdtree.vim +source ~/.config/nvim/plugins/telescope.vim +source ~/.config/nvim/plugins/treesitter.vim diff --git a/.config/nvim/plugins/aerial.vim b/.config/nvim/plugins/aerial.vim new file mode 100644 index 0000000..9a6db49 --- /dev/null +++ b/.config/nvim/plugins/aerial.vim @@ -0,0 +1,28 @@ +lua <<EOF +require('aerial').setup({ + filter_kind = false, +}) + +require('telescope').load_extension('aerial') +EOF + +nnoremap <leader>a <cmd>AerialToggle!<CR> +nnoremap <leader>fa <cmd>Telescope aerial<CR> + +" add aerial to tab switch filetypes +call add(g:NERDTreeStatusLineTabSwitchFiletypes, 'aerial') + +" close Aerial and NERDTree if they are the only remaining windows +function AerialNERDTreeClose() + if winnr('$') != 2 + return + endif + + let window_filetypes = UtilityWinfiletypes() + + if index(window_filetypes, 'aerial') != -1 && index(window_filetypes, 'nerdtree') != -1 + " one quit suffices, since aerial and nerdtree close themselves + quit + endif +endfunction +autocmd BufEnter * call AerialNERDTreeClose() diff --git a/.config/nvim/plugins/comment.vim b/.config/nvim/plugins/comment.vim new file mode 100644 index 0000000..3b150b6 --- /dev/null +++ b/.config/nvim/plugins/comment.vim @@ -0,0 +1,3 @@ +lua <<EOF +require('Comment').setup() +EOF diff --git a/.config/nvim/plugins/gitgutter.vim b/.config/nvim/plugins/gitgutter.vim new file mode 100644 index 0000000..5099e57 --- /dev/null +++ b/.config/nvim/plugins/gitgutter.vim @@ -0,0 +1,2 @@ +nnoremap <leader>gp <cmd>GitGutterPreviewHunk<CR> +nnoremap <leader>gu <cmd>GitGutterUndoHunk<CR> diff --git a/.config/nvim/plugins/indent_blankline.vim b/.config/nvim/plugins/indent_blankline.vim new file mode 100644 index 0000000..227ac86 --- /dev/null +++ b/.config/nvim/plugins/indent_blankline.vim @@ -0,0 +1,11 @@ +lua <<EOF +vim.api.nvim_set_hl(0, 'IndentBlanklineChar', { fg = '#303030', nocombine = true }) +vim.api.nvim_set_hl(0, 'IndentBlanklineContextChar', { fg = '#404040', nocombine = true }) + +require('indent_blankline').setup { + use_treesitter = true, + show_first_indent_level = false, + show_trailing_blankline_indent = false, + show_current_context = true, +} +EOF diff --git a/.config/nvim/plugins/leap.vim b/.config/nvim/plugins/leap.vim new file mode 100644 index 0000000..be63380 --- /dev/null +++ b/.config/nvim/plugins/leap.vim @@ -0,0 +1,3 @@ +lua <<EOF +require('leap').add_default_mappings() +EOF diff --git a/.config/nvim/plugins/lsp.vim b/.config/nvim/plugins/lsp.vim new file mode 100644 index 0000000..d0f6f26 --- /dev/null +++ b/.config/nvim/plugins/lsp.vim @@ -0,0 +1,91 @@ +lua <<EOF +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + -- Enable completion triggered by <c-x><c-o> + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + + -- See :help vim.lsp.* for documentation on any of the below functions + buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) + buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) + buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) + buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) + buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) + buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) + buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) + buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts) + buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) + buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) + buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) + buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) + buf_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts) + buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts) + buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts) + buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts) + buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.format({async = true})<CR>', opts) +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + +vim.o.completeopt = 'menuone,noselect' + +require('mason').setup() +require('mason-lspconfig').setup() +require('mason-lspconfig').setup_handlers { + function (server_name) + require ('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, + } + end +} + +local cmp = require('cmp') +local luasnip = require('luasnip') +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = { + ['<C-p>'] = cmp.mapping.select_prev_item(), + ['<C-n>'] = cmp.mapping.select_next_item(), + ['<C-d>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.close(), + ['<CR>'] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + ['<Tab>'] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, + ['<S-Tab>'] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} +EOF diff --git a/.config/nvim/plugins/markdown_preview.vim b/.config/nvim/plugins/markdown_preview.vim new file mode 100644 index 0000000..03ff94f --- /dev/null +++ b/.config/nvim/plugins/markdown_preview.vim @@ -0,0 +1,3 @@ +let g:mkdp_preview_options = { + \ 'disable_sync_scroll': 1 +\ } diff --git a/.config/nvim/plugins/nerdtree.vim b/.config/nvim/plugins/nerdtree.vim new file mode 100644 index 0000000..8a7869a --- /dev/null +++ b/.config/nvim/plugins/nerdtree.vim @@ -0,0 +1,33 @@ +let g:NERDTreeShowHidden=1 +let g:NERDTreeGitStatusShowIgnored=1 + +if !&diff + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * NERDTree | if argc() > 0 || exists('s:std_in') | wincmd p | endif + autocmd VimEnter * if argc() > 0 | silent NERDTreeFind | wincmd p | endif +endif + +autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif + +" set status line on tab switch +function NERDTreeStatusLineTabSwitch() + let tab_nr = tabpagenr() + let buffer_list = tabpagebuflist(tab_nr) + + " default to 2 + let meaningful_window_nr = 2 + + for buffer_nr in buffer_list + let buffer_type = getbufvar(buffer_nr, "&filetype") + if index(g:NERDTreeStatusLineTabSwitchFiletypes, buffer_type) == -1 + let meaningful_window_nr = bufwinnr(buffer_nr) + break + endif + endfor + + exe meaningful_window_nr .. "wincmd w" +endfunction +autocmd TabLeave * call NERDTreeStatusLineTabSwitch() + +map <C-b> <cmd>NERDTreeToggle<CR> diff --git a/.config/nvim/plugins/telescope.vim b/.config/nvim/plugins/telescope.vim new file mode 100644 index 0000000..729edad --- /dev/null +++ b/.config/nvim/plugins/telescope.vim @@ -0,0 +1,3 @@ +nnoremap <leader>ff <cmd>Telescope find_files<CR> +nnoremap <leader>fg <cmd>Telescope live_grep<CR> +nnoremap <leader><leader> <cmd>Telescope buffers<CR> diff --git a/.config/nvim/plugins/treesitter.vim b/.config/nvim/plugins/treesitter.vim new file mode 100644 index 0000000..6f12bd0 --- /dev/null +++ b/.config/nvim/plugins/treesitter.vim @@ -0,0 +1,13 @@ +lua <<EOF +require('nvim-treesitter.configs').setup { + ensure_installed = 'all', + sync_install = false, + indent = { + enable = true, + }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, +} +EOF |