From 2243a7fd58faafb5cb4d2ab3947b3adab8eeb475 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 18 Jan 2023 13:38:08 +0100 Subject: [nvim] reorganize config and plugins --- .config/nvim/init.vim | 344 +------------------------------------------------- 1 file changed, 5 insertions(+), 339 deletions(-) (limited to '.config/nvim/init.vim') diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index de616e9..7c59a81 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -1,92 +1,4 @@ -" " -" Plugins -" " - -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' - -call plug#end() - - -" " -" Config -" " - -nnoremap -let mapleader=" " - -set shiftwidth=2 -set tabstop=2 -set expandtab - -set list -set listchars=tab:\ \ ,trail:- - -set mouse=a -set splitright - -set updatetime=250 - -" ruler -set relativenumber number -augroup numbertoggle - autocmd! - autocmd BufEnter,WinEnter * if &nu && mode() != 'i' | set relativenumber | endif - autocmd BufLeave,WinLeave * if &nu | set norelativenumber | endif -augroup END - -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 :p") | quit - -function! s:winfiletypes() +function UtilityWinfiletypes() let winfiletypes = [] for window_nr in range(1, winnr('$')) let filetype = getbufvar(winbufnr(window_nr), '&filetype') @@ -96,256 +8,10 @@ function! s:winfiletypes() return winfiletypes endfunction - -" Nerdtree - -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 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 NERDTreeToggle - - -" Telescope - -nnoremap ff Telescope find_files -nnoremap fg Telescope live_grep -nnoremap Telescope buffers - - -" GitGutter - -nnoremap gp GitGutterPreviewHunk -nnoremap gu GitGutterUndoHunk - - -" Leap - -lua <a AerialToggle! -nnoremap fa Telescope aerial - -" 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 < - 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', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) - buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) - buf_set_keymap('n', 'f', 'lua vim.lsp.buf.format({async = true})', 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 = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, - [''] = 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 - - -" " -" Keys -" " - -" buffer pane navigation -nnoremap -nnoremap -nnoremap -nnoremap - -nnoremap tabprevious -nnoremap tabnext - -" esc / quit -map -nnoremap q -" save -nnoremap w -inoremap w +source ~/.config/nvim/plugins/_install.vim +source ~/.config/nvim/config/config.vim +source ~/.config/nvim/config/keys.vim +source ~/.config/nvim/plugins/_load.vim -- cgit v1.2.3