diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..fb65a8d --- /dev/null +++ b/.flake8 @@ -0,0 +1,14 @@ +[flake8] +ignore = + BLK100, + # line too long + E501, + # Missing docstring + D100, + D101, + D102, + D103 + D104, + D105, + D106, + D107 diff --git a/.gitignore b/.gitignore index 6a65871..d87f6b4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ vim.bundle .VimballRecord plugged rplugin.vim +plugin/packer_compiled.lua diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..8f4a02f --- /dev/null +++ b/.luarc.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.diagnostics.disable": ["undefined-global"] +} + diff --git a/LUL9KAMW.vim b/LUL9KAMW.vim deleted file mode 100644 index bf3d37a..0000000 --- a/LUL9KAMW.vim +++ /dev/null @@ -1,5 +0,0 @@ -" =================Python============================== -let g:python3_host_prog="c:\\Scoop\\apps\\python\\current\\python.exe" -let g:python_host_prog="c:\\Python27\\python.exe" -" ===================Chromatica====================== -let g:chromatica#libclang_path='C:\Tools\LLVM\bin\libclang.dll' diff --git a/UUL4JKMG.vim b/UUL4JKMG.vim deleted file mode 100644 index 083203c..0000000 --- a/UUL4JKMG.vim +++ /dev/null @@ -1,5 +0,0 @@ -" =================Python============================== -let g:python3_host_prog="d:\\Scoop\\apps\\python\\current\\python.exe" -let g:python_host_prog="c:\\Python27\\python.exe" -" ===================Chromatica====================== -let g:chromatica#libclang_path='D:\Tools\LLVM\bin\libclang.dll' diff --git a/coc-settings.json b/coc-settings.json deleted file mode 100644 index c1e478b..0000000 --- a/coc-settings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "languageserver": { - "cquery": { - "command": "cquery", - "args": ["--log-file=/tmp/cq.log"], - "filetypes": ["c", "cpp"], - "rootPatterns": ["compile_flags.txt", "compile_commands.json", ".vim/", ".git/", ".hg/"], - "initializationOptions": { - "cacheDirectory": "/tmp/cquery" - } - } - } -} diff --git a/coc-settings_win.json b/coc-settings_win.json deleted file mode 100644 index d24889b..0000000 --- a/coc-settings_win.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "languageserver": { - "clangd": { - "command": "clangd", - "filetypes": ["c", "cpp"], - "rootPatterns": ["compile_flags.txt", "compile_commands.json", ".vim/", ".git/", ".hg/"] - } - } -} diff --git a/editWithNVimQT.reg b/editWithNVimQT.reg new file mode 100644 index 0000000..f9d3668 --- /dev/null +++ b/editWithNVimQT.reg @@ -0,0 +1,6 @@ +Windows Registry Editor Version 5.00 + +[HKEY_CURRENT_USER\SOFTWARE\Classes\*\shell\Open with Neovim] + +[HKEY_CURRENT_USER\SOFTWARE\Classes\*\shell\Open with Neovim\command] +@="cmd /c start nvim-qt.exe -- -- \"%1\"" diff --git a/ginit.vim b/ginit.vim deleted file mode 100644 index 2534b5a..0000000 --- a/ginit.vim +++ /dev/null @@ -1,21 +0,0 @@ -" set mouse=a -if has("win32") - Guifont! Consolas:h10 -else - " Guifont DejaVu Sans Mono:h10 - " Guifont Liberation Mono for Powerline:h9 - " Guifont Droid Sans Mono for Powerline:h10 - Guifont Source Code Pro for Powerline:h10 - " Guifont Terminess Powerline:h10 -end -" Paste with middle mouse click -vmap "*ygv - -" Paste with + -imap * - -" Use the default popup menu -GuiPopupmenu 0 - -:set guioptions=mlrb - diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..7ad4f77 --- /dev/null +++ b/init.lua @@ -0,0 +1,135 @@ +local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd') +local fn = vim.fn -- to call Vim functions e.g. fn.bufnr() +local g = vim.g -- a table to access global variables +local opt = vim.opt -- to set options +local utils = require('utils') + +-------------------- PACKER -------------------------------- +-- Auto install packer.nvim if not exists +local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +if fn.empty(fn.glob(install_path)) > 0 then + fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) + vim.cmd 'packadd packer.nvim' +end +vim.cmd [[packadd packer.nvim]] +-------------------- EXTERNAL ------------------------------ +require('my_plugins') +require('my_keymappings') +require('my_options') +require("my_autocommands") + +-- plugins +require('my_telescope') +require('my_lspinstall') +require('my_cmp') +-------------------- TREE-SITTER --------------------------- +require('nvim-treesitter.configs').setup({ + ensure_installed = 'maintained', + highlight = { + enable = true + } +}) +-------------------- GITSIGNS ------------------------------ +require('gitsigns').setup() +-------------------- NVIM-TREE ----------------------------- +require('nvim-tree').setup({ + auto_close = true, + update_cwd = true, + update_to_buf_dir = { + -- enable the feature + enable = true, + -- allow to open the tree if it was previously closed + auto_open = false, + }, + update_focused_file = { + enable = true, + update_cwd = false, + ignore_list = {} + }, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + } + }, +}) +utils.map('n', 'tt', 'NvimTreeToggle') +g.nvim_tree_highlight_opened_files = 1 +g.nvim_tree_respect_buf_cwd = 1 +-------------------- COMMENTED ----------------------------- +require('Comment').setup({ + toggler = { + ---line-comment toggle + line = 'cc', + }, + opleader = { + ---line-comment opfunc mapping + line = 'c', + }, +}) +-------------------- CMAKE --------------------------------- +require('telescope').load_extension('cmake') +require('cmake').setup({ + parameters_file = 'neovim.json', -- JSON file to store information about selected target, run arguments and build type. + build_dir = '{cwd}/build_nvim', -- Build directory. The expressions `{cwd}`, `{os}` and `{build_type}` will be expanded with the corresponding text values. +}) +utils.map('n', '', ':CMake build:copen') + +-- msbuild errorformat +opt.errorformat:append("\\ %#%f(%l\\\\\\,%c):\\ %m") +-- cl.exe errorformat +-- o.errorformat:append('\ %#%f(%l) : %#%t%[A-z]%# %m') + +-------------------- NEOCLIP ------------------------------- +require('neoclip').setup({ + default_register = '+', +}) +require('telescope').load_extension('neoclip') +-------------------- LUALINE ------------------------------- +require('lualine').setup { + options = {theme = 'gruvbox'}, + sections = {lualine_c = {'getcwd', 'filename', 'nvim_treesitter#statusline'}, + } +} +-------------------- PROJECT ------------------------------- +require("project_nvim").setup { + silent_chdir = true, +} +require('telescope').load_extension('projects') +utils.map('n', 'p', 'Telescope projects') +-------------------- TS-RAINBOW ---------------------------- +require'nvim-treesitter.configs'.setup { + rainbow = { + enable = true, + extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean + max_file_lines = nil, -- Do not enable for files with more than n lines, int + -- colors = {}, -- table of hex strings + -- termcolors = {} -- table of colour name strings + } +} +-------------------- LUASNIP ------------------------------- +require("luasnip.loaders.from_vscode").load() +-------------------- AUTOPAIRS ----------------------------- +require('nvim-autopairs').setup{} +-------------------- FZF NATIVE ---------------------------- +require('telescope').load_extension('fzf') +-------------------- TERMINAL ------------------------------ +require('nvim-terminal').setup({ + toggle_keymap = 'z', +}) +-------------------- INDENT-BLANKLINE ---------------------- +opt.listchars:append("eol:↴") +-- opt.listchars:append("space: ") +opt.listchars:append("trail: ") +opt.listchars:append("tab:→ ") + +require("indent_blankline").setup { + show_end_of_line = true, + use_treesitter = true, + show_current_context = true, + context_patterns = {'class', 'function', 'method', 'block', '^if', '^for', '^while'}, +} + diff --git a/init.vim b/init.vim deleted file mode 100644 index 58e9866..0000000 --- a/init.vim +++ /dev/null @@ -1,332 +0,0 @@ -let HOSTNAME = substitute(system('hostname'), '\n', '', '') -" =============Plugins================== -if !exists('g:vscode') - call plug#begin() - Plug 'morhetz/gruvbox' - Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' } - Plug 'chemzqm/denite-git' - Plug 'tomtom/tcomment_vim' - Plug 'bling/vim-airline' - Plug 'vim-airline/vim-airline-themes' - " Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } - Plug 'tpope/vim-fugitive' - Plug 'airblade/vim-gitgutter' - Plug 'SirVer/ultisnips' - Plug 'honza/vim-snippets' - Plug 'vim-scripts/a.vim' - Plug 'luochen1990/rainbow' - if has("win32") - Plug 'autozimu/LanguageClient-neovim', { - \ 'branch': 'next', - \ 'do': 'powershell -executionpolicy bypass -File install.ps1', - \ } - else - Plug 'autozimu/LanguageClient-neovim', { - \ 'branch': 'next', - \ 'do': 'bash install.sh', - \ } - end - Plug 'Shougo/echodoc.vim' - Plug 'arakashic/chromatica.nvim', { 'do': ':UpdateRemotePlugins' } - Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}} - Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'} - Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} - Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'} - Plug 'neoclide/coc-highlight', {'do': 'yarn install --frozen-lockfile'} - Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'} - Plug 'neoclide/coc-lists', {'do': 'yarn install --frozen-lockfile'} - Plug 'kkoomen/vim-doge' - call plug#end() -endif -" =============Paths===================== -exec "source " . stdpath('config') . "/" . hostname() . ".vim" -" =============Settings================== -filetype plugin on -filetype indent on -set nocompatible -set ignorecase " Case sensitive off -set incsearch -set encoding=utf-8 -set nobackup -set noswapfile -set mouse=a -set spelllang=en,de -set spellsuggest=double,10 -set list -set icon -set listchars=tab:>.,trail:.,extends:#,nbsp:. -set showmatch " Show pair braces -set hlsearch "Highlight search -syntax on -set number -set scrolloff=2 -set autochdir " Always switch to directory of current buffer -let mapleader = "," - -set title - -if has("win32") - " set rop=type:directx - let g:loaded_matchparen = 1 -end - -set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣ -set listchars=eol:⏎,tab:␉·,trail:␠,nbsp:⎵ -set listchars=tab:>.,trail:.,extends:#,nbsp:. - -" set clipboard+=unnamedplus " use system clipboard -" " Copy to clipboard -vnoremap y "+y -nnoremap Y "+yg_ -nnoremap y "+y -nnoremap yy "+yy - -" " Paste from clipboard -nnoremap p "+p -nnoremap P "+P -vnoremap p "+p -vnoremap P "+P - -autocmd BufEnter,FocusGained * checktime " Check for file modifications - -" =================Look and feel======================= -if !exists('g:vscode') - set termguicolors - set background=dark - colorscheme gruvbox -endif -" =================Filetypes=========================== -if !exists('g:vscode') - au BufRead,BufNewFile *.simvis set filetype=xml - au BufRead,BufNewFile *.simcfg set filetype=cfg - au BufRead,BufNewFile *.simcon set filetype=cfg - au BufRead,BufNewFile *.simudex set filetype=cfg - au BufRead,BufNewFile Jenkinsfile* set filetype=groovy - autocmd BufNewFile,BufRead *.manifest set filetype=xml - autocmd BufNewFile,BufReadPre SConstruct set filetype=python - autocmd BufNewFile,BufReadPre SConscript set filetype=python - autocmd FileType xml nnoremap :% !xmllint.exe "%" --format - autocmd FileType json syntax match Comment +\/\/.\+$+ -endif -" =================Windows and Tabs==================== -if !exists('g:vscode') - " Open a new tab with F2 - map :tabnew :Explore - imap :tabnew :Explore - map :tabnext - map :tabprevious - nmap :wincmd k - nmap :wincmd j - nmap :wincmd h - nmap :wincmd l - " Open a new vertical split window with Ctrl - F2 - map :vsplit . - imap :vsplit . - " Open a new horizontal split window with Shift - F2 - map :split . - imap :split . -endif - -" ========================Codestyle======================== -if !exists('g:vscode') - set tabstop=2 " Size of a tab - set shiftwidth=2 " Die Einrückung - set expandtab "Tabs get spaces when inserting - set softtabstop=0 - "set autoindent - "alignment ansi style (astyle) - set cindent " C-Code Style / Automatische Einrückung - set cinoptions=(0,u0,U0,:0,=0 "Einrückung wie bei astyle: :0 (switch), =0 (case), (0 (unclosed parentheses), - set modeline "Read indent comments (at end of file) -endif - -" ======================shortcut======================= -if !exists('g:vscode') - map :wa - imap :wa -endif -"Jump to last modification line -map ö `. -nnoremap ü :let @/='\<=expand("")\>':set hls -vnoremap ü : - \let old_reg=getreg('"')let old_regtype=getregtype('"') - \gvy:let @/=substitute( - \escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g') - \gV:call setreg('"', old_reg, old_regtype):set hls - -"map jump back to ctrl+- -nnoremap -"===================Reselect visual block after indent/outdent============ -vnoremap < >gv - -" ===========Linewrap and jumping============================= -if !exists('g:vscode') - setlocal wrap linebreak nolist - set virtualedit= - setlocal display+=lastline - nnoremap k gk - nnoremap j gj - nnoremap 0 g0 - nnoremap $ g$ - nnoremap gk - nnoremap gj - nnoremap g - nnoremap g - vnoremap gk - vnoremap gj - vnoremap g - vnoremap g -endif - -" =================Comments============================ -if !exists('g:vscode') - map :TComment -endif - -" =========================Deoplete==================== -if !exists('g:vscode') - let g:deoplete#enable_at_startup = 1 - let g:deoplete#auto_complete_start_length = 1 - let g:deoplete#enable_smart_case = 1 -endif -" =====================A====================== -if !exists('g:vscode') - " Function for switching between header and c* files - map :wa :A - imap :wa:Ai - map :AV - imap :AVi - map :AT - imap :ATi - let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,../../include,sfr:../inc,sfr:../h' - " Dont create the file if the .cpp or .h is not found - let g:alternateNoDefaultAlternate = 1 - - " ===================UltiSnips================ - let g:UltiSnipsExpandTrigger = "(ultisnips_expand)" - let g:UltiSnipsJumpForwardTrigger = "" - let g:UltiSnipsJumpBackwardTrigger = "" - " ===========RAINBOW==================== - let g:rainbow_active = 1 - let g:rainbow_conf = { - \ 'guifgs': ['lightblue', 'darkorange3', 'seagreen3', 'firebrick'], - \ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'], - \ 'operators': '_,_', - \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'], - \ 'separately': { - \ '*': {}, - \ 'tex': { - \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'], - \ }, - \ 'cpp': { - \ 'parentheses': [ - \ 'start=/(/ end=/)/ fold', - \ 'start=/\[/ end=/\]/ fold', - \ 'start=/{/ end=/}/ fold', - \ 'start=/\(\(\\)\@/'] - \ }, - \ 'cmake': { - \ 'parentheses': [], - \ }, - \ 'lisp': { - \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], - \ }, - \ 'vim': { - \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'], - \ }, - \ 'html': { - \ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=## fold'], - \ }, - \ 'css': 0, - \ } - \} -endif -" ===================LanguageServer================== -if !exists('g:vscode') - if has("win32") - let g:LanguageClient_serverCommands = { - \ 'cpp': ['clangd'], - \ } - else - let g:LanguageClient_serverCommands = { - \ 'cpp': ['cquery', - \ '--log-file=/tmp/cq.log', - \ '--init={"cacheDirectory":"/tmp/cquery/"}'] - \ } - end - nnoremap K :call LanguageClient#textDocument_hover() - nnoremap gd :call LanguageClient#textDocument_definition({'gotoCmd': 'tabedit'}) - nnoremap :call LanguageClient_contextMenu() - vnoremap :call LanguageClient_contextMenu() - nnoremap :call LanguageClient_textDocument_documentSymbol() - - let g:LanguageClient_hasClientSupport = 0 - " ===================EchoDoc========================= - set cmdheight=2 - let g:echodoc#enable_at_startup = 1 - let g:echodoc#type = 'signature' -endif -" ===================FZF============================= -if !exists('g:vscode') - nnoremap :FZF - let g:fzf_action = { - \ 'enter': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit' } -endif -" ===================Chromatica====================== -if !exists('g:vscode') - let g:chromatica#enable_at_startup=1 -endif - -" ===================COC============================= -if !exists('g:vscode') - inoremap coc#refresh() - autocmd CursorHold * silent call CocActionAsync('highlight') - set updatetime=500 " After ms should CursorHold trigger - " Remap for format selected region - vmap f (coc-format-selected) - nmap f (coc-format-selected) - -nmap r (coc-rename) -" Use `:Format` for format current buffer -command! -nargs=0 Format :call CocAction('format') -" Shortcuts for denite interface -" Show extension list -nnoremap e :CocList extensions -" Show symbols of current buffer -nnoremap o :CocList outline -" Search symbols of current workspace -nnoremap t :CocList symbols -" Show diagnostics of current workspace -nnoremap a :CocList diagnostics -" Show available commands -nnoremap c :CocList commands -" Show available services -nnoremap s :CocList services -" Show links of current buffer -nnoremap l :CocList link -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) -" Use K for show documentation in preview window -nnoremap K :call show_documentation() -function! s:show_documentation() - if &filetype == 'vim' - execute 'h '.expand('') - else - call CocAction('doHover') - endif -endfunction - -nnoremap y :CocList -A --normal yank -" ===================Denite========================== -if !exists('g:vscode') - call denite#custom#map('insert', '', '', 'noremap') - call denite#custom#map('insert', '', '', 'noremap') - - nnoremap :Denite -default-action=tabopen file/rec - nnoremap :Denite buffer -endif diff --git a/lua/my_autocommands.lua b/lua/my_autocommands.lua new file mode 100644 index 0000000..3fb7b3e --- /dev/null +++ b/lua/my_autocommands.lua @@ -0,0 +1,45 @@ +function nvim_create_augroups(definitions) + for group_name, definition in pairs(definitions) do + vim.cmd('augroup ' .. group_name) + vim.cmd('autocmd!') + for _, def in ipairs(definition) do + local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ') + vim.cmd(command) + end + vim.cmd('augroup END') + end +end + +local autocmds = { + packer = { + { 'BufWritePost', 'plugins.lua', 'PackerCompile' }; + }; + restore_cursor = { + { 'BufRead', '*', [[call setpos(".", getpos("'\""))]] }; + }; + save_shada = { + {'FocusGained,FocusLost', '*', 'rshada|wshada'}; + }; + resize_windows_proportionally = { + { 'VimResized', '*', ':wincmd =' }; + }; + lua_highlight = { + { 'TextYankPost', '*', [[silent! lua vim.highlight.on_yank() {higroup='IncSearch', timeout=400}]] }; + }; + file_type = { + {'BufRead,BufNewFile', '*.simvis', 'set filetype=xml'}; + {'BufRead,BufNewFile', '*.simcfg,*.simcon,*.simudex', 'set filetype=cfg'}; + {'BufRead,BufNewFile', 'Jenkinsfile*', 'set filetype=groovy'}; + {'BufRead,BufNewFile', '*.manifest', 'set filetype=xml'}; + {'BufRead,BufNewFile', 'SConstruct,SConscript', 'set filetype=python'}; + }; + file_changed = { + {'BufEnter,FocusGained', '*', 'checktime'}; + }; + no_auto_comment = { + {'BufEnter', '*', 'set fo-=c fo-=r fo-=o'} + } +} + +nvim_create_augroups(autocmds) + diff --git a/lua/my_cmp.lua b/lua/my_cmp.lua new file mode 100644 index 0000000..0e5c7c5 --- /dev/null +++ b/lua/my_cmp.lua @@ -0,0 +1,118 @@ +local cmp = require('cmp') +local luasnip = require("luasnip") + +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + +local check_back_space = function() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") ~= nil +end + +cmp.setup { + + formatting = { + format = function(entry, vim_item) + -- fancy icons and a name of kind + vim_item.kind = require("lspkind").presets.default[vim_item.kind] .. + " " .. vim_item.kind + -- set a name for each source + vim_item.menu = ({ + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + ultisnips = "[UltiSnips]", + nvim_lua = "[Lua]", + cmp_tabnine = "[TabNine]", + look = "[Look]", + path = "[Path]", + spell = "[Spell]", + calc = "[Calc]", + emoji = "[Emoji]" + })[entry.source.name] + return vim_item + end + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's'}), + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), + [''] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }), + [''] = cmp.mapping({ + i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }), + c = cmp.mapping.confirm({ select = false }), + s = cmp.mapping.confirm({ select = false }), + }), + [""] = cmp.mapping(function(fallback) + if luasnip.expand_or_jumpable() then + vim.api.nvim_feedkeys(t("luasnip-expand-or-jump"), "", true) + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + vim.api.nvim_feedkeys(t("luasnip-jump-prev"), "", true) + else + fallback() + end + end, { + "i", + "s", + }), + }, + snippet = { + expand = function(args) + require'luasnip'.lsp_expand(args.body) + end + }, + sources = { + {name = 'nvim_lsp'}, {name = 'buffer'}, {name = "luasnip"}, + {name = "nvim_lua"}, {name = "look"}, {name = "path"}, + {name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"}, + {name = "emoji"} + }, + completion = {completeopt = 'menu,menuone,noinsert, noselect'}, + -- experimental = { native_menu = true } +} + +-- 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' } + }, { + { name = 'buffer' } + }), +}) + +-- Autopairs +--require("nvim-autopairs.completion.cmp").setup({ +-- map_cr = true, +-- map_complete = true, +-- auto_select = true +--}) +local cmp_autopairs = require('nvim-autopairs.completion.cmp') +cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) + +-- TabNine +--local tabnine = require('cmp_tabnine.config') +--tabnine:setup({max_lines = 1000, max_num_results = 20, sort = true}) + +-- Database completion +vim.api.nvim_exec([[ +autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer({ sources = {{ name = 'vim-dadbod-completion' }} }) +]], false) diff --git a/lua/my_keymappings.lua b/lua/my_keymappings.lua new file mode 100644 index 0000000..e941744 --- /dev/null +++ b/lua/my_keymappings.lua @@ -0,0 +1,90 @@ +local utils = require('utils') +vim.g.mapleader = ',' +-- Paste from clipboard +utils.map('n', 'p', '"+p') +utils.map('n', 'P', '"+P') +utils.map('v', 'p', '"+p') +utils.map('v', 'P', '"+P') + +-- Yank to clipboard +utils.map('v', 'y', '"+y') +utils.map('n', 'Y', '"+yg_') +utils.map('n', 'y', '"+y') +utils.map('n', 'yy', '"+yy') + +-- Tabs +utils.map('n', '', ':tabnew .', { noremap = true, silent = true }) +utils.map('i', '', ':tabnew .', { noremap = true, silent = true }) +-- utils.map('n', '', ':BufferLineCycleNext') +-- utils.map('n', '', ':BufferLineCyclePrev') +utils.map('n', '', ':tabnext', { noremap = true, silent = true }) +utils.map('n', '', ':tabprevious', { noremap = true, silent = true }) +-- Split movement +utils.map('n', '', ':wincmd k', { noremap = true, silent = true }) +utils.map('n', '', ':wincmd j', { noremap = true, silent = true }) +utils.map('n', '', ':wincmd h', { noremap = true, silent = true }) +utils.map('n', '', ':wincmd l', { noremap = true, silent = true }) +-- Open a new vertical split window with Ctrl - F2 +utils.map('n', '', ':vsplit .', { noremap = true, silent = true }) +utils.map('i', '', ':vsplit .', { noremap = true, silent = true }) +-- Open a new horizontal split window with Shift - F2 +utils.map('n', '', ':split .', { noremap = true, silent = true }) +utils.map('i', '', ':split .', { noremap = true, silent = true }) + +utils.map('n', '', ':wa') + +-- Linewrap and jumping +utils.map('n', 'k', 'gk') +utils.map('n', 'j', 'gj') +utils.map('n', '0', 'g0') +utils.map('n', '$', 'g$') +utils.map('n', '', 'gk') +utils.map('n', '', 'gj') +utils.map('n', '', 'g') +utils.map('n', '', 'g') +utils.map('v', 'k', 'gk') +utils.map('v', 'j', 'gj') +utils.map('v', '0', 'g0') +utils.map('v', '$', 'g$') +utils.map('v', '', 'gk') +utils.map('v', '', 'gj') +utils.map('v', '', 'g') +utils.map('v', '', 'g') + +utils.map('v', '<', '', '>gv') + +-- Highlight word under cursor +utils.map('n', 'ü', ":let @/='\\<=expand(\"\")\\>':set hls", { noremap = true, silent = true }) +utils.map('v', 'ü', "y:let @/='=escape(@\",'/\\')':set hls") utils.map('v', 'ü', "y:let @/='=escape(@\",'/\\')':set hls", { noremap = true, silent = true }) + +-- Close Buffer +utils.map('n', '', ':bd') + +-- to navigate the completion menu +utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) +utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) + +-- Telescope +utils.map('n', 'f', 'Telescope find_files') +utils.map('n', '', 'Telescope find_files') +utils.map('n', 'g', 'Telescope git_files') +utils.map('n', 'o', 'Telescope oldfiles') +utils.map('n', 'h', 'Telescope command_history') +utils.map('v', 'h', 'Telescope command_history') +utils.map('n', '', 'Telescope commands') +utils.map('n', 'b', 'Telescope buffers') +utils.map('n', 'q', 'Telescope quickfix') +utils.map('n', 'l', 'Telescope live_grep') +utils.map('n', 'r', 'Telescope lsp_references') +utils.map('n', '', 'Telescope lsp_document_symbols') +utils.map('n', '', 'Telescope lsp_document_symbols') +utils.map('n', 'v', 'Telescope diagnostics bufnr=0') +utils.map('n', '', 'Telescope neoclip') +utils.map('n', 'j', 'Telescope jumplist') + +-- wildmode + +-- Symbols Outline +utils.map('n', 's', 'SymbolsOutline') + diff --git a/lua/my_lspinstall.lua b/lua/my_lspinstall.lua new file mode 100644 index 0000000..0647ab8 --- /dev/null +++ b/lua/my_lspinstall.lua @@ -0,0 +1,108 @@ +local utils = require('utils') + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.documentationFormat = { 'markdown', 'plaintext' } +capabilities.textDocument.completion.completionItem.snippetSupport = true +capabilities.textDocument.completion.completionItem.preselectSupport = true +capabilities.textDocument.completion.completionItem.insertReplaceSupport = true +capabilities.textDocument.completion.completionItem.labelDetailsSupport = true +capabilities.textDocument.completion.completionItem.deprecatedSupport = true +capabilities.textDocument.completion.completionItem.commitCharactersSupport = true +capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } } +capabilities.textDocument.completion.completionItem.resolveSupport = { + properties = { + 'documentation', + 'detail', + 'additionalTextEdits', + }, +} + +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 + + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + utils.map('n', ',', 'lua vim.lsp.diagnostic.goto_prev()', opts) + utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()', opts) + utils.map('n', 'a', 'Telescope lsp_code_actions', opts) + utils.map('n', 'd', 'lua vim.lsp.buf.definition()', opts) + utils.map('n', 'e', 'lua vim.lsp.buf.declaration()', opts) + utils.map('n', 'h', 'lua vim.lsp.buf.hover()', opts) + utils.map('n', 'c', 'lua vim.lsp.buf.outgoing_calls()', opts) + utils.map('n', 'C', 'lua vim.lsp.buf.incoming_calls()', opts) + utils.map('n', 'm', 'lua vim.lsp.buf.rename()', opts) + -- utils.map('n', 'r', 'lua vim.lsp.buf.references()') + utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()', opts) + utils.map('n', '', 'Telescope lsp_dynamic_workspace_symbols', opts) + utils.map('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + utils.map('n', '', 'lua vim.lsp.buf.signature_help()', opts) + utils.map('n', 'r', 'Telescope lsp_references') + utils.map('n', '', 'Telescope lsp_document_symbols') + utils.map('n', '', 'Telescope lsp_document_symbols') + utils.map('n', 'v', 'Telescope diagnostics bufnr=0') + utils.map('n', '', ':ClangdSwitchSourceHeader', opts) + + -- Set some keybinds conditional on server capabilities + if client.resolved_capabilities.document_formatting then + utils.map('n', 'f', 'lua vim.lsp.buf.formatting()', opts) + end + if client.resolved_capabilities.document_range_formatting then + utils.map('v', 'f', 'lua vim.lsp.buf.range_formatting()', opts) + end + + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec([[ + hi LspReferenceRead cterm=bold ctermbg=red guibg=DarkGreen + hi LspReferenceText cterm=bold ctermbg=Black guibg=DarkYellow guifg=Black + hi LspReferenceWrite cterm=bold ctermbg=red guibg=DarkRed + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorHoldI lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]], false) + end + require "lsp_signature".on_attach({ + bind = true, -- This is mandatory, otherwise border config won't get registered. + handler_opts = { + border = "single" + }, + hi_parameter = "IncSearch" + }, bufnr) +end + +local lsp_installer = require("nvim-lsp-installer") +lsp_installer.on_server_ready(function(server) + local opts = { + on_attach = on_attach, + capabilities = capabilities, + } + + -- (optional) Customize the options passed to the server + -- if server.name == "tsserver" then + -- opts.root_dir = function() ... end + -- end + + -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) + server:setup(opts) + vim.cmd [[ do User LspAttachBuffers ]] +end) + +local null_ls = require("null-ls") +null_ls.setup { + sources = { + null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.formatting.autopep8, + null_ls.builtins.formatting.prettier, + null_ls.builtins.formatting.stylua, + null_ls.builtins.diagnostics.flake8, + null_ls.builtins.formatting.isort + }, + on_attach = on_attach, + capabilities = capabilities +} diff --git a/lua/my_options.lua b/lua/my_options.lua new file mode 100644 index 0000000..9801817 --- /dev/null +++ b/lua/my_options.lua @@ -0,0 +1,35 @@ +local utils = require('utils') +vim.cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme here +vim.cmd 'syntax enable' +vim.cmd 'filetype plugin indent on' +vim.cmd 'language en_US.utf-8' +utils.opt('o', 'hlsearch', true) +utils.opt('o', 'guifont', 'Hack NF:h9') +utils.opt('o', 'swapfile', false) +utils.opt('o', 'backup', false) +utils.opt('o', 'spelllang', 'en,de') +local indent = 2 +utils.opt('b', 'expandtab', true) +utils.opt('b', 'shiftwidth', indent) +utils.opt('b', 'smartindent', true) +utils.opt('b', 'tabstop', indent) +utils.opt('o', 'hidden', true) +utils.opt('o', 'ignorecase', true) +utils.opt('o', 'scrolloff', 4 ) +utils.opt('o', 'shiftround', true) +utils.opt('o', 'relativenumber', false) +utils.opt('o', 'smartcase', true) +utils.opt('o', 'splitbelow', true) +utils.opt('o', 'splitright', true) +utils.opt('o', 'wildmode', 'longest:full,full') +utils.opt('w', 'number', true) +utils.opt('o', 'clipboard', 'unnamed,unnamedplus') +utils.opt('o', 'mouse', 'a') +utils.opt('o', 'wrap', false) +utils.opt('o', 'termguicolors', true) +utils.opt('o', 'splitbelow', true) +utils.opt('o', 'splitright', true) +utils.opt('o', 'list', true) +utils.opt('o', 'updatetime', 300) +utils.opt('o', 'wrap', true) +utils.opt('o', 'showmatch', true) diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua new file mode 100644 index 0000000..8c080b3 --- /dev/null +++ b/lua/my_plugins.lua @@ -0,0 +1,55 @@ +return require('packer').startup(function() + + -- Packer can manage itself as an optional plugin + use {'wbthomason/packer.nvim'} + use {'neovim/nvim-lspconfig'} + use {'nvim-treesitter/nvim-treesitter'} + use { + 'nvim-telescope/telescope.nvim', + requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}, {'kyazdani42/nvim-web-devicons'}} + } + use {'sainnhe/gruvbox-material'} + use {'lukas-reineke/indent-blankline.nvim'} + use {'nvim-lua/plenary.nvim'} + use {'lewis6991/gitsigns.nvim'} + use { + 'kyazdani42/nvim-tree.lua', + requires = 'kyazdani42/nvim-web-devicons' + } + use{'numToStr/Comment.nvim'} + use { + 'hrsh7th/nvim-cmp', + requires = { + 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp', + 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-nvim-lua', + 'octaltree/cmp-look', 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc', + 'f3fora/cmp-spell', 'hrsh7th/cmp-emoji', 'hrsh7th/cmp-cmdline' + } + } + use {'rafamadriz/friendly-snippets'} + use {'onsails/lspkind-nvim'} + use {'Shatur/neovim-cmake', + requires = {'mfussenegger/nvim-dap'} + } + use {'AckslD/nvim-neoclip.lua'} + use { + 'hoob3rt/lualine.nvim', + requires = {'kyazdani42/nvim-web-devicons', opt = true} + } + use {'ahmedkhalf/project.nvim'} + use {'p00f/nvim-ts-rainbow'} + use {'simrat39/symbols-outline.nvim'} + use {'f-person/git-blame.nvim'} + use {'windwp/nvim-autopairs'} + use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'} + use {'ray-x/lsp_signature.nvim'} + use {'s1n7ax/nvim-terminal'} + use { + 'williamboman/nvim-lsp-installer', + requires = {'neovim/nvim-lspconfig'} + } + use { + 'jose-elias-alvarez/null-ls.nvim', + requires = {'nvim-lua/plenary.nvim'} + } +end) diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua new file mode 100644 index 0000000..23d08e7 --- /dev/null +++ b/lua/my_telescope.lua @@ -0,0 +1,48 @@ +local actions = require('telescope.actions') + +local mappingTab = { + i = { + [''] = actions.select_tab, + [''] = actions.select_default, + } +} + +require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = actions.close, + [''] = actions.select_default + actions.center, + [''] = actions.send_selected_to_loclist, + [''] = actions.smart_send_to_qflist + } + } + }, + pickers = { + -- Your special builtin config goes in here + buffers = { + sort_lastused = true, + theme = 'ivy', + mappings = { + i = { + [''] = actions.delete_buffer, + [''] = actions.select_default, + }, + n = { + [''] = actions.delete_buffer, + } + } + }, + find_files = { + theme = 'ivy', + }, + oldfiles = { + theme = 'ivy', + }, + git_files = { + theme = 'ivy', + }, + lsp_dynamic_workspace_symbols = { + }, + } +} diff --git a/lua/utils/init.lua b/lua/utils/init.lua new file mode 100644 index 0000000..2d1f40b --- /dev/null +++ b/lua/utils/init.lua @@ -0,0 +1,16 @@ +local utils = { } + +local scopes = {o = vim.o, b = vim.bo, w = vim.wo} + +function utils.opt(scope, key, value) + scopes[scope][key] = value + if scope ~= 'o' then scopes['o'][key] = value end +end + +function utils.map(mode, lhs, rhs, opts) + local options = {noremap = true} + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +return utils \ No newline at end of file diff --git a/perryLinux64.vim b/perryLinux64.vim deleted file mode 100644 index 636cdfe..0000000 --- a/perryLinux64.vim +++ /dev/null @@ -1,4 +0,0 @@ -" =================Python============================== -" let g:python3_host_prog="/usr/bin/python3" -" let g:python_host_prog="/usr/bin/python2" -" ===================Chromatica====================== diff --git a/perryWin64.vim b/perryWin64.vim deleted file mode 100644 index 14c8d0c..0000000 --- a/perryWin64.vim +++ /dev/null @@ -1,5 +0,0 @@ -" =================Python============================== -let g:python3_host_prog="f:\\Tools\\Python\\python.exe" -let g:python_host_prog="f:\\Tools\\Python27\\python.exe" -" ===================Chromatica====================== -let g:chromatica#libclang_path='F:\Tools\LLVM\bin\libclang.dll'