summaryrefslogtreecommitdiff
path: root/.config/nvim/init.vim
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-01-12 11:24:35 +0100
committerDaniel Weipert <code@drogueronin.de>2023-10-30 09:52:23 +0100
commit41cc0c57cde2517f774c05147e2d5bcc9813f724 (patch)
treec45fee3f2d1dc17e44bed1b5c47f0940aaff357c /.config/nvim/init.vim
parent8a33339d4e17f047d3b63d752d1cde8de4f81bf7 (diff)
[nvim] overhaul config and plugins
Diffstat (limited to '.config/nvim/init.vim')
-rw-r--r--.config/nvim/init.vim97
1 files changed, 91 insertions, 6 deletions
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim
index 43fb173..de616e9 100644
--- a/.config/nvim/init.vim
+++ b/.config/nvim/init.vim
@@ -6,8 +6,10 @@ call plug#begin(stdpath('data') . '/plugged')
Plug 'doums/darcula'
-Plug 'preservim/nerdtree'
Plug 'ryanoasis/vim-devicons'
+Plug 'nvim-tree/nvim-web-devicons'
+
+Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'nvim-lua/plenary.nvim'
@@ -23,11 +25,16 @@ 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'
@@ -72,6 +79,23 @@ colorscheme darcula
set termguicolors
hi Normal guibg=NONE ctermbg=NONE
+if &diff
+ autocmd BufEnter * if winnr('$') == 1 | quit | endif
+endif
+
+" pdf
+autocmd BufEnter *.pdf split | exe expandcmd("terminal firefox <afile>:p") | quit
+
+function! s:winfiletypes()
+ let winfiletypes = []
+ for window_nr in range(1, winnr('$'))
+ let filetype = getbufvar(winbufnr(window_nr), '&filetype')
+ call add(winfiletypes, filetype)
+ endfor
+
+ return winfiletypes
+endfunction
+
" Nerdtree
@@ -87,11 +111,32 @@ 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
+let g:NERDTreeStatusLineTabSwitchFiletypes = ["nerdtree", "help"]
+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>
" Telescope
-
+
nnoremap <leader>ff <cmd>Telescope find_files<CR>
nnoremap <leader>fg <cmd>Telescope live_grep<CR>
nnoremap <leader><leader> <cmd>Telescope buffers<CR>
@@ -106,7 +151,7 @@ nnoremap <leader>gu <cmd>GitGutterUndoHunk<CR>
" Leap
lua <<EOF
-require('leap').set_default_keymaps()
+require('leap').add_default_mappings()
EOF
@@ -114,8 +159,8 @@ EOF
lua <<EOF
require('nvim-treesitter.configs').setup {
- ensure_installed = 'maintained', -- one of "all", "maintained" (parsers with maintainers), or a list of languages
- sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)
+ ensure_installed = 'all',
+ sync_install = false,
indent = {
enable = true,
},
@@ -128,6 +173,7 @@ EOF
" Indent Blankline
+
lua <<EOF
vim.cmd [[highlight IndentBlanklineChar guifg=#303030 gui=nocombine]]
vim.cmd [[highlight IndentBlanklineContextChar guifg=#404040 gui=nocombine]]
@@ -148,6 +194,45 @@ let g:mkdp_preview_options = {
\ }
+" Aerial
+
+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 = s:winfiletypes()
+
+ 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()
+
+
+" Comment
+
+lua <<EOF
+require('Comment').setup()
+EOF
+
+
" LSP
lua <<EOF
@@ -182,7 +267,7 @@ local on_attach = function(client, bufnr)
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
-capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
+capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
vim.o.completeopt = 'menuone,noselect'