set nocompatible " Plugins call plug#begin() " navigation Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' "Plug 'ap/vim-buftabline' Plug 'nvim-lua/plenary.nvim' " needed by harpoon Plug 'ThePrimeagen/harpoon' Plug 'christoomey/vim-tmux-navigator' " statusline Plug 'nvim-lualine/lualine.nvim' Plug 'kyazdani42/nvim-web-devicons' " lsp/completion Plug 'neovim/nvim-lspconfig' Plug 'hrsh7th/nvim-cmp' Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-nvim-lua' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'onsails/lspkind-nvim' " misc plugins Plug 'tpope/vim-fugitive' Plug 'lewis6991/gitsigns.nvim' Plug 'vim-syntastic/syntastic' " colorschemes Plug 'mhinz/vim-janah' Plug 'lifepillar/vim-solarized8' Plug 'morhetz/gruvbox' Plug 'RRethy/nvim-base16' " plugins to evaluate: vim-gitgutter, vim-fugitive, snippets and completion stuff call plug#end() " vim-buftabline settings "let g:buftabline_show = 1 let g:buftabline_numbers = 2 " nvim-cmp settings set completeopt=menu,menuone,noselect lua <'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. [''] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close(), }), [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }, sources = cmp.config.sources({ }, { { name = "nvim_lsp" }, { name = 'buffer' }, { name = "path" }, { name = "nvim_lua" }, }), formatting = { format = lspkind.cmp_format { with_text = true, menu = { buffer = "[buf]", nvim_lsp = "[LSP]", nvim_lua = "[api]", path = "[path]", cmdline = "[cmd]", }, }, }, }) -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline('/', { sources = { { name = 'buffer' } } }) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline(':', { sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) }) -- Setup lspconfig local nvim_lsp = require('lspconfig') -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end 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', 'R', 'lua vim.lsp.buf.rename()', opts) -- buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) buf_set_keymap('n', 'o', '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.formatting()', opts) end -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local servers = { 'pyright' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach, flags = { debounce_text_changes = 150, } } end -- disable lsp overlay warning/error messages vim.diagnostic.config { virtual_text = false, signs = false, underline = false, } -- configure lualine require('lualine').setup({ sections = { lualine_a = {'mode'}, lualine_b = { {'filename', path = 1} }, -- relative path lualine_c = {'branch', 'diff', 'diagnostics'}, lualine_x = {'encoding', 'fileformat', 'filetype'}, lualine_y = {'progress'}, lualine_z = {'location'} }, }) -- configure gitsigns require('gitsigns').setup() -- configure harpoon local mark = require("harpoon.mark") local ui = require("harpoon.ui") vim.keymap.set("n", "m", mark.add_file) vim.keymap.set("n", "h", ui.toggle_quick_menu) vim.keymap.set("n", "1", function() ui.nav_file(1) end) vim.keymap.set("n", "2", function() ui.nav_file(2) end) vim.keymap.set("n", "3", function() ui.nav_file(3) end) vim.keymap.set("n", "4", function() ui.nav_file(4) end) vim.keymap.set("n", "5", function() ui.nav_file(5) end) vim.keymap.set("n", "6", function() ui.nav_file(6) end) vim.keymap.set("n", "7", function() ui.nav_file(7) end) vim.keymap.set("n", "8", function() ui.nav_file(8) end) vim.keymap.set("n", "9", function() ui.nav_file(9) end) vim.keymap.set("n", "0", function() ui.nav_file(10) end) EOF " Syntastic settings let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 1 "let g:syntastic_always_populate_loc_list = 1 "let g:syntastic_auto_loc_list = 1 let g:syntastic_auto_jump = 1 let g:syntastic_lua_checkers = ["luac", "luacheck"] " general behaviour set nocompatible " behave like vim set backspace=indent,eol,start " Entf und Backspace loeschen auch Zeilen filetype plugin indent on " detect the type of file set history=1000 " How many lines of history to remember set hidden " you can change buffer without saving set ttimeoutlen=50 " timeout for key sequences set scrolloff=3 " keep 3 lines above/below the cursor " backup, swap and undo file settings set backupdir=~/.vim/backup// set directory=~/.vim/swap// set undodir=~/.vim/undo// set writebackup " indentation settings set autoindent " copy indentation from the previous line " clipboard: use PRIMARY, with xclip set clipboard+=unnamed " mouse settings set mouse=a " enable mouse for all modes if !has('nvim') set ttymouse=xterm2 " fix vim mouse support in tmux endif "set paste " Pasten mit der Maus " general display settings set title " Titel anzeigen set ruler " Cursorposition anzeigen set cursorline " highlight line with cursor set number "relativenumber " Zeilennummern anzeigen, optional mit relativenumber set colorcolumn=80 set wrap "set statusline=[%n]\ %f\ \ %y\ \ %m%r%h%w\ \ (%l,%v)\ \ %p%% set laststatus=2 " always show the status line set wildmenu " show cmdline completion results in a horizontal menu above the cmdline " define characters for displaying special characters and enable them set listchars=tab:▸\ ,trail:·,eol:¬,extends:❯,precedes:❮ set list set showbreak=↪ " code display settings set encoding=utf-8 syntax enable " Syntax Highlighting an set termguicolors " enable 24-bit colors - some colorschemes need this set showmatch " Zeigt korrespondierende Klammern " search/replace settings set ignorecase " case doesn't matter in searches set smartcase " search casesensitive if 1+ chars are uppercase set incsearch " highlight as you type you search phrase set hlsearch " highlight all search results set gdefault " replace all occurences in a line without explicit 'g' " netrw (explorer) settings let g:netrw_banner = 0 " hide banner let g:netrw_liststyle = 3 "let g:netrw_browse_split = 4 " open file in previous window "let g:netrw_winsize = 25 " width in percent " colorschemes "colorscheme desert "colorscheme morning "colorscheme janah colorscheme base16-bright " solarized8 variants "set background=dark "set background=light "colorscheme solarized8_high "colorscheme solarized8 "colorscheme solarized8_low "colorscheme solarized8_flat " gruvbox variants "let g:gruvbox_contrast_dark = 'hard' "let g:gruvbox_contrast_dark = 'medium' "let g:gruvbox_contrast_dark = 'soft' "let g:gruvbox_contrast_light = 'hard' "let g:gruvbox_contrast_light = 'medium' "let g:gruvbox_contrast_light = 'soft' "colorscheme gruvbox "set background=dark "set background=light " keybindings let mapleader = "\" " save current buffer nnoremap w :w " close current buffer nnoremap c :bp:bw # " force close current buffer (closing also the window) nnoremap C :close " fuzzy search for files (fzf) nnoremap p :Files " jump to previous search result nnoremap k :cp " jump to next search result nnoremap j :cn " open file explorer nnoremap e :Explore " go to the specific buffer "nmap 1 BufTabLine.Go(1) "nmap 2 BufTabLine.Go(2) "nmap 3 BufTabLine.Go(3) "nmap 4 BufTabLine.Go(4) "nmap 5 BufTabLine.Go(5) "nmap 6 BufTabLine.Go(6) "nmap 7 BufTabLine.Go(7) "nmap 8 BufTabLine.Go(8) "nmap 9 BufTabLine.Go(9) "nmap 0 BufTabLine.Go(10) " use grep to search for a string typed in nnoremap f :grep! -R '' . " use grep to search for the word under the cursor nnoremap F :execute "grep! -R '".expand("")."' .":copen "nnoremap F :execute "grep! -R '".expand("")."' ." " search and replace in current file nnoremap r :%s//XXX/gc " fugitive status view nnoremap g :0G " clear search highlight nnoremap :nohlsearch " Alt + h/l: previous/next buffer map :bp map :bn " Keep half-page up/down in the middle of the window nnoremap zz nnoremap zz " Keep search matches in the middle of the window nnoremap n nzzzv nnoremap N Nzzzv " Search for word under cursor but do not jump to next occurence nnoremap * *N " gui settings if has('gui_running') "set guioptions-=m " no menu set guioptions-=T " no toolbar set guioptions-=L " no left scrollbar set guioptions-=r " no left scrollbar set guifont=DejaVu\ Sans\ Mono\ 9 "set guifont=Terminus\ 8 endif