Merge branch 'lua'

# Conflicts:
#	init.vim
This commit is contained in:
Oliver Hartmann 2021-12-21 21:52:54 +01:00
commit 8fabdb2d07
21 changed files with 676 additions and 394 deletions

14
.flake8 Normal file
View File

@ -0,0 +1,14 @@
[flake8]
ignore =
BLK100,
# line too long
E501,
# Missing docstring
D100,
D101,
D102,
D103
D104,
D105,
D106,
D107

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ vim.bundle
.VimballRecord
plugged
rplugin.vim
plugin/packer_compiled.lua

5
.luarc.json Normal file
View File

@ -0,0 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.diagnostics.disable": ["undefined-global"]
}

View File

@ -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'

View File

@ -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'

View File

@ -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"
}
}
}
}

View File

@ -1,9 +0,0 @@
{
"languageserver": {
"clangd": {
"command": "clangd",
"filetypes": ["c", "cpp"],
"rootPatterns": ["compile_flags.txt", "compile_commands.json", ".vim/", ".git/", ".hg/"]
}
}
}

6
editWithNVimQT.reg Normal file
View File

@ -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\""

View File

@ -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 <LeftRelease> "*ygv
" Paste with <Shift> + <Insert>
imap <S-Insert> <C-R>*
" Use the default popup menu
GuiPopupmenu 0
:set guioptions=mlrb

135
init.lua Normal file
View File

@ -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', '<leader>tt', '<cmd>NvimTreeToggle<CR>')
g.nvim_tree_highlight_opened_files = 1
g.nvim_tree_respect_buf_cwd = 1
-------------------- COMMENTED -----------------------------
require('Comment').setup({
toggler = {
---line-comment toggle
line = '<leader>cc',
},
opleader = {
---line-comment opfunc mapping
line = '<leader>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', '<F5>', ':CMake build<CR>:copen<CR>')
-- 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', '<space>p', '<cmd>Telescope projects<cr>')
-------------------- 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 = '<leader>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'},
}

332
init.vim
View File

@ -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 <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
nnoremap <leader>yy "+yy
" " Paste from clipboard
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>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 <F10> :% !xmllint.exe "%" --format<CR>
autocmd FileType json syntax match Comment +\/\/.\+$+
endif
" =================Windows and Tabs====================
if !exists('g:vscode')
" Open a new tab with F2
map <silent> <F2> <Esc>:tabnew <CR><ESC>:Explore<CR>
imap <silent> <F2> <Esc>:tabnew <CR><ESC>:Explore<CR>
map <silent> <S-Right> :tabnext<CR>
map <silent> <S-Left> :tabprevious<CR>
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
" Open a new vertical split window with Ctrl - F2
map <silent> <C-F2> <Esc>:vsplit .<CR>
imap <silent> <C-F2> <Esc>:vsplit .<CR>
" Open a new horizontal split window with Shift - F2
map <silent> <S-F2> <Esc>:split .<CR>
imap <silent> <S-F2> <Esc>:split .<CR>
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 <C-S> <ESC>:wa<CR>
imap <C-S> <ESC>:wa<CR>
endif
"Jump to last modification line
map ö `.
nnoremap ü :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
vnoremap <silent> ü :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy:let @/=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>:set hls<CR>
"map jump back to ctrl+-
nnoremap <C--> <C-O>
"===================Reselect visual block after indent/outdent============
vnoremap < <gv
vnoremap > >gv
" ===========Linewrap and jumping=============================
if !exists('g:vscode')
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
nnoremap <silent> k gk
nnoremap <silent> j gj
nnoremap <silent> 0 g0
nnoremap <silent> $ g$
nnoremap <silent> <Up> gk
nnoremap <silent> <Down> gj
nnoremap <silent> <Home> g<Home>
nnoremap <silent> <End> g<End>
vnoremap <silent> <Up> gk
vnoremap <silent> <Down> gj
vnoremap <silent> <Home> g<Home>
vnoremap <silent> <End> g<End>
endif
" =================Comments============================
if !exists('g:vscode')
map <C-C> :TComment<CR>
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 <F5> :wa <CR> :A<CR>
imap <F5> <Esc>:wa<CR>:A<CR>i
map <C-F5> :AV<CR>
imap <C-F5> <Esc>:AV<CR>i
map <S-F5> :AT<CR>
imap <S-F5> <Esc>:AT<CR>i
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 = "<Plug>(ultisnips_expand)"
let g:UltiSnipsJumpForwardTrigger = "<Tab>"
let g:UltiSnipsJumpBackwardTrigger = "<S-Tab>"
" ===========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=/\(\(\<operator\>\)\@<!<\)\&[a-zA-Z0-9_]\@<=<\ze[^<]/ end=/>/']
\ },
\ '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=#</\z1># 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 <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition({'gotoCmd': 'tabedit'})<CR>
nnoremap <silent> <F3> :call LanguageClient_contextMenu()<CR>
vnoremap <silent> <F3> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> <F6> :call LanguageClient_textDocument_documentSymbol()<CR>
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 <C-P> :FZF<CR>
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 <silent><expr> <c-space> coc#refresh()
autocmd CursorHold * silent call CocActionAsync('highlight')
set updatetime=500 " After ms should CursorHold trigger
" Remap for format selected region
vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
nmap <leader>r <Plug>(coc-rename)
" Use `:Format` for format current buffer
command! -nargs=0 Format :call CocAction('format')
" Shortcuts for denite interface
" Show extension list
nnoremap <silent> <space>e :CocList extensions<cr>
" Show symbols of current buffer
nnoremap <silent> <space>o :CocList outline<cr>
" Search symbols of current workspace
nnoremap <silent> <space>t :CocList symbols<cr>
" Show diagnostics of current workspace
nnoremap <silent> <space>a :CocList diagnostics<cr>
" Show available commands
nnoremap <silent> <space>c :CocList commands<cr>
" Show available services
nnoremap <silent> <space>s :CocList services<cr>
" Show links of current buffer
nnoremap <silent> <space>l :CocList link<cr>
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K for show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
nnoremap <silent> <space>y :<C-u>CocList -A --normal yank<cr>
" ===================Denite==========================
if !exists('g:vscode')
call denite#custom#map('insert', '<Down>', '<denite:move_to_next_line>', 'noremap')
call denite#custom#map('insert', '<Up>', '<denite:move_to_previous_line>', 'noremap')
nnoremap <C-P> :Denite -default-action=tabopen file/rec<CR>
nnoremap <C-B> :Denite buffer<CR>
endif

45
lua/my_autocommands.lua Normal file
View File

@ -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)

118
lua/my_cmp.lua Normal file
View File

@ -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 = {
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's'}),
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }),
['<C-e>'] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }),
['<CR>'] = cmp.mapping({
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
c = cmp.mapping.confirm({ select = false }),
s = cmp.mapping.confirm({ select = false }),
}),
["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
vim.api.nvim_feedkeys(t("<Plug>luasnip-expand-or-jump"), "", true)
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
vim.api.nvim_feedkeys(t("<Plug>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)

90
lua/my_keymappings.lua Normal file
View File

@ -0,0 +1,90 @@
local utils = require('utils')
vim.g.mapleader = ','
-- Paste from clipboard
utils.map('n', '<leader>p', '"+p')
utils.map('n', '<leader>P', '"+P')
utils.map('v', '<leader>p', '"+p')
utils.map('v', '<leader>P', '"+P')
-- Yank to clipboard
utils.map('v', '<leader>y', '"+y')
utils.map('n', '<leader>Y', '"+yg_')
utils.map('n', '<leader>y', '"+y')
utils.map('n', '<leader>yy', '"+yy')
-- Tabs
utils.map('n', '<F2>', ':tabnew .<CR>', { noremap = true, silent = true })
utils.map('i', '<F2>', '<Esc>:tabnew .<CR>', { noremap = true, silent = true })
-- utils.map('n', '<S-Right>', ':BufferLineCycleNext<CR>')
-- utils.map('n', '<S-Left>', ':BufferLineCyclePrev<CR>')
utils.map('n', '<S-Right>', ':tabnext<CR>', { noremap = true, silent = true })
utils.map('n', '<S-Left>', ':tabprevious<CR>', { noremap = true, silent = true })
-- Split movement
utils.map('n', '<A-Up>', ':wincmd k<CR>', { noremap = true, silent = true })
utils.map('n', '<A-Down>', ':wincmd j<CR>', { noremap = true, silent = true })
utils.map('n', '<A-Left>', ':wincmd h<CR>', { noremap = true, silent = true })
utils.map('n', '<A-Right>', ':wincmd l<CR>', { noremap = true, silent = true })
-- Open a new vertical split window with Ctrl - F2
utils.map('n', '<C-F2>', ':vsplit .<CR>', { noremap = true, silent = true })
utils.map('i', '<C-F2>', '<Esc>:vsplit .<CR>', { noremap = true, silent = true })
-- Open a new horizontal split window with Shift - F2
utils.map('n', '<S-F2>', ':split .<CR>', { noremap = true, silent = true })
utils.map('i', '<S-F2>', '<Esc>:split .<CR>', { noremap = true, silent = true })
utils.map('n', '<C-S>', ':wa<CR>')
-- 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', '<Up>', 'gk')
utils.map('n', '<Down>', 'gj')
utils.map('n', '<Home>', 'g<Home>')
utils.map('n', '<End>', 'g<End>')
utils.map('v', 'k', 'gk')
utils.map('v', 'j', 'gj')
utils.map('v', '0', 'g0')
utils.map('v', '$', 'g$')
utils.map('v', '<Up>', 'gk')
utils.map('v', '<Down>', 'gj')
utils.map('v', '<Home>', 'g<Home>')
utils.map('v', '<End>', 'g<End>')
utils.map('v', '<', '<gv')
utils.map('v', '>', '>gv')
-- Highlight word under cursor
utils.map('n', 'ü', ":let @/='\\<<C-R>=expand(\"<cword>\")<CR>\\>'<CR>:set hls<CR>", { noremap = true, silent = true })
utils.map('v', 'ü', "y:let @/='<C-R>=escape(@\",'/\\')<CR>'<CR>:set hls<CR>") utils.map('v', 'ü', "y:let @/='<C-R>=escape(@\",'/\\')<CR>'<CR>:set hls<CR>", { noremap = true, silent = true })
-- Close Buffer
utils.map('n', '<C-w>', ':bd<CR>')
-- <Tab> to navigate the completion menu
utils.map('i', '<S-Tab>', 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true})
utils.map('i', '<Tab>', 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true})
-- Telescope
utils.map('n', '<leader>f', '<cmd>Telescope find_files<cr>')
utils.map('n', '<C-p>', '<cmd>Telescope find_files<cr>')
utils.map('n', '<leader>g', '<cmd>Telescope git_files<cr>')
utils.map('n', '<leader>o', '<cmd>Telescope oldfiles<cr>')
utils.map('n', '<leader>h', '<cmd>Telescope command_history<cr>')
utils.map('v', '<leader>h', '<cmd>Telescope command_history<cr>')
utils.map('n', '<C-S-p>', '<cmd>Telescope commands<cr>')
utils.map('n', '<leader>b', '<cmd>Telescope buffers<cr>')
utils.map('n', '<leader>q', '<cmd>Telescope quickfix<cr>')
utils.map('n', '<leader>l', '<cmd>Telescope live_grep<cr>')
utils.map('n', '<space>r', '<cmd>Telescope lsp_references<cr>')
utils.map('n', '<C-S-o>', '<cmd>Telescope lsp_document_symbols<cr>')
utils.map('n', '<A-m>', '<cmd>Telescope lsp_document_symbols<cr>')
utils.map('n', '<space>v', '<cmd>Telescope diagnostics bufnr=0<cr>')
utils.map('n', '<C-y>', '<cmd>Telescope neoclip<cr>')
utils.map('n', '<leader>j', '<cmd>Telescope jumplist<cr>')
-- wildmode
-- Symbols Outline
utils.map('n', '<leader>s', '<cmd>SymbolsOutline<cr>')

108
lua/my_lspinstall.lua Normal file
View File

@ -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', '<space>,', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
utils.map('n', '<space>;', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
utils.map('n', '<space>a', '<cmd>Telescope lsp_code_actions<CR>', opts)
utils.map('n', '<space>d', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
utils.map('n', '<space>e', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
utils.map('n', '<space>h', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
utils.map('n', '<space>c', '<cmd>lua vim.lsp.buf.outgoing_calls()<CR>', opts)
utils.map('n', '<space>C', '<cmd>lua vim.lsp.buf.incoming_calls()<CR>', opts)
utils.map('n', '<space>m', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
-- utils.map('n', '<space>r', '<cmd>lua vim.lsp.buf.references()<CR, opts>')
utils.map('n', '<space>s', '<cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
utils.map('n', '<C-t>', '<cmd>Telescope lsp_dynamic_workspace_symbols<CR>', opts)
utils.map('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
utils.map('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
utils.map('n', '<space>r', '<cmd>Telescope lsp_references<cr>')
utils.map('n', '<C-S-o>', '<cmd>Telescope lsp_document_symbols<cr>')
utils.map('n', '<A-m>', '<cmd>Telescope lsp_document_symbols<cr>')
utils.map('n', '<space>v', '<cmd>Telescope diagnostics bufnr=0<cr>')
utils.map('n', '<A-o>', ':ClangdSwitchSourceHeader<CR>', opts)
-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
utils.map('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
if client.resolved_capabilities.document_range_formatting then
utils.map('v', '<space>f', '<esc><cmd>lua vim.lsp.buf.range_formatting()<CR>', 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! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> 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
}

35
lua/my_options.lua Normal file
View File

@ -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)

55
lua/my_plugins.lua Normal file
View File

@ -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)

48
lua/my_telescope.lua Normal file
View File

@ -0,0 +1,48 @@
local actions = require('telescope.actions')
local mappingTab = {
i = {
['<cr>'] = actions.select_tab,
['<C-b>'] = actions.select_default,
}
}
require('telescope').setup {
defaults = {
mappings = {
i = {
['<esc>'] = actions.close,
['<cr>'] = actions.select_default + actions.center,
['<C-l>'] = actions.send_selected_to_loclist,
['<C-q>'] = actions.smart_send_to_qflist
}
}
},
pickers = {
-- Your special builtin config goes in here
buffers = {
sort_lastused = true,
theme = 'ivy',
mappings = {
i = {
['<c-w>'] = actions.delete_buffer,
['<cr>'] = actions.select_default,
},
n = {
['<c-w>'] = actions.delete_buffer,
}
}
},
find_files = {
theme = 'ivy',
},
oldfiles = {
theme = 'ivy',
},
git_files = {
theme = 'ivy',
},
lsp_dynamic_workspace_symbols = {
},
}
}

16
lua/utils/init.lua Normal file
View File

@ -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

View File

@ -1,4 +0,0 @@
" =================Python==============================
" let g:python3_host_prog="/usr/bin/python3"
" let g:python_host_prog="/usr/bin/python2"
" ===================Chromatica======================

View File

@ -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'