From f38e21f648807c27f2483ab5e86b6b690a7cf767 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 7 Sep 2021 21:08:02 +0200 Subject: [PATCH 001/114] Move from vim script to lua init file --- init.lua | 87 +++++++++++++ init.vim | 305 -------------------------------------------- lua/keymappings.lua | 16 +++ lua/plugins.lua | 16 +++ lua/utils/init.lua | 16 +++ 5 files changed, 135 insertions(+), 305 deletions(-) create mode 100644 init.lua delete mode 100644 init.vim create mode 100644 lua/keymappings.lua create mode 100644 lua/plugins.lua create mode 100644 lua/utils/init.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..5faa983 --- /dev/null +++ b/init.lua @@ -0,0 +1,87 @@ +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 fn = vim.fn + +-- Auto install packer.nvim if not exists +local fn = vim.fn +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]] +vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are changes in plugins.lua + +local utils = require('utils') +-- Install plugins +require('plugins') +require('keymappings') +-------------------- OPTIONS ------------------------------- +cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme here +cmd 'syntax enable' +cmd 'filetype plugin indent on' +--opt.noswapfile = true +-- opt.nobackup = true +opt.spelllang = 'en,de' +local indent = 4 +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', true) +utils.opt('o', 'smartcase', true) +utils.opt('o', 'splitbelow', true) +utils.opt('o', 'splitright', true) +utils.opt('o', 'wildmode', 'list:longest') +utils.opt('w', 'number', true) +utils.opt('w', 'relativenumber', 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) + +-- Highlight on yank +vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' + +-------------------- MAPPINGS ------------------------------ +-- to navigate the completion menu +utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) +utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) +-------------------- TREE-SITTER --------------------------- +local ts = require 'nvim-treesitter.configs' +ts.setup {ensure_installed = 'maintained', highlight = {enable = true}} + +-------------------- FZF ----------------------------------- +utils.map('n', '', ':FZF') +-------------------- LSP ----------------------------------- +local lsp = require 'lspconfig' + +-- We use the default settings for ccls and pylsp: the option table can stay empty +lsp.ccls.setup {} +lsp.pyright.setup{} +lsp.clangd.setup{} + +utils.map('n', ',', 'lua vim.lsp.diagnostic.goto_prev()') +utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()') +utils.map('n', 'a', 'lua vim.lsp.buf.code_action()') +utils.map('n', 'd', 'lua vim.lsp.buf.definition()') +utils.map('n', 'f', 'lua vim.lsp.buf.formatting()') +utils.map('n', 'h', 'lua vim.lsp.buf.hover()') +utils.map('n', 'm', 'lua vim.lsp.buf.rename()') +utils.map('n', 'r', 'lua vim.lsp.buf.references()') +utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') + +-------------------- GITSIGNS ------------------------------ +require('gitsigns').setup() +-------------------- LIGHTBULB ----------------------------- +require('nvim-lightbulb').update_lightbulb() diff --git a/init.vim b/init.vim deleted file mode 100644 index 1adef2b..0000000 --- a/init.vim +++ /dev/null @@ -1,305 +0,0 @@ -let HOSTNAME = substitute(system('hostname'), '\n', '', '') -" =============Plugins================== -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() - -" =============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======================= -set termguicolors -set background=dark -colorscheme gruvbox -" =================Filetypes=========================== -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 +\/\/.\+$+ -" =================Windows and Tabs==================== -" 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 . - -" ========================Codestyle======================== -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) - -" ======================shortcut======================= -map :wa -imap :wa -"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============================= -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 - -" =================Comments============================ -map :TComment - -" =========================Deoplete==================== -let g:deoplete#enable_at_startup = 1 -let g:deoplete#auto_complete_start_length = 1 -let g:deoplete#enable_smart_case = 1 -" =====================A====================== -" 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, - \ } - \} - -" ===================LanguageServer================== -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' -" ===================FZF============================= -nnoremap :FZF -let g:fzf_action = { - \ 'enter': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit' } -" ===================Chromatica====================== -let g:chromatica#enable_at_startup=1 - -" ===================COC============================= -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========================== -call denite#custom#map('insert', '', '', 'noremap') -call denite#custom#map('insert', '', '', 'noremap') - -nnoremap :Denite -default-action=tabopen file/rec -nnoremap :Denite buffer diff --git a/lua/keymappings.lua b/lua/keymappings.lua new file mode 100644 index 0000000..b367f5e --- /dev/null +++ b/lua/keymappings.lua @@ -0,0 +1,16 @@ +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 and Split + +utils.map('n', 'F2', ':tabnew .') diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..068bb39 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,16 @@ +return require('packer').startup(function() + + -- Packer can manage itself as an optional plugin + use {'wbthomason/packer.nvim', opt = true} + use {'neovim/nvim-lspconfig'} + use {'nvim-treesitter/nvim-treesitter'} + use { + 'nvim-telescope/telescope.nvim', + requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} + } + use {'sainnhe/gruvbox-material'} + use {'lukas-reineke/indent-blankline.nvim'} + use {'nvim-lua/plenary.nvim'} + use {'lewis6991/gitsigns.nvim'} + use {'kosayoda/nvim-lightbulb'} +end) 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 From f4fe34a7aa7c5a56d2c54263a0defec592b35ad6 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 7 Sep 2021 21:08:17 +0200 Subject: [PATCH 002/114] Added editWithNvim reg file --- editWithNVimQT.reg | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 editWithNVimQT.reg 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\"" From 1d0a458c8f9918a606c712b8f42dbec52a1e2d47 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 00:13:06 +0200 Subject: [PATCH 003/114] Added completion and some key mappings --- init.lua | 106 ++++++++++++++++++++++++++++++++++++++++---- lua/cmp_plug.lua | 93 ++++++++++++++++++++++++++++++++++++++ lua/keymappings.lua | 18 +++++++- lua/plugins.lua | 15 +++++++ 4 files changed, 222 insertions(+), 10 deletions(-) create mode 100644 lua/cmp_plug.lua diff --git a/init.lua b/init.lua index 5faa983..1e2b018 100644 --- a/init.lua +++ b/init.lua @@ -13,8 +13,12 @@ if fn.empty(fn.glob(install_path)) > 0 then vim.cmd 'packadd packer.nvim' end vim.cmd [[packadd packer.nvim]] -vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are changes in plugins.lua - +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerCompile + augroup end +]]) local utils = require('utils') -- Install plugins require('plugins') @@ -23,10 +27,10 @@ require('keymappings') cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme here cmd 'syntax enable' cmd 'filetype plugin indent on' ---opt.noswapfile = true --- opt.nobackup = true -opt.spelllang = 'en,de' -local indent = 4 +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) @@ -62,7 +66,15 @@ local ts = require 'nvim-treesitter.configs' ts.setup {ensure_installed = 'maintained', highlight = {enable = true}} -------------------- FZF ----------------------------------- -utils.map('n', '', ':FZF') +--utils.map('n', '', ':FZF') +-------------------- 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('n', '', 'Telescope commands') +utils.map('n', 'fb', 'Telescope buffers') -------------------- LSP ----------------------------------- local lsp = require 'lspconfig' @@ -82,6 +94,84 @@ utils.map('n', 'r', 'lua vim.lsp.buf.references()') utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') -------------------- GITSIGNS ------------------------------ -require('gitsigns').setup() +-- require('gitsigns').setup() -------------------- LIGHTBULB ----------------------------- require('nvim-lightbulb').update_lightbulb() +-------------------- CMP ----------------------------------- +require('cmp_plug') +-- local cmp = require'cmp' +-- cmp.setup({ +-- snippet = { +-- expand = function(args) +-- vim.fn["vsnip#anonymous"](args.body) +-- end, +-- }, +-- mapping = { +-- [''] = cmp.mapping.confirm({ select = true }), +-- }, +-- sources = { +-- { name = '...' }, +-- ... +-- } +-- }) +-- local cmp = require 'cmp' +-- local types = require('cmp.types') +-- cmp.setup { +-- completion = { +-- autocomplete = { +-- types.cmp.TriggerEvent.TextChanged, +-- }, +-- completeopt = 'menu,menuone,noselect', +-- keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]], +-- keyword_length = 1, +-- get_trigger_characters = function(trigger_characters) +-- return trigger_characters +-- end +-- }, +-- snippet = { +-- expand = function(args) +-- require('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 vim.fn.pumvisible() == 1 then +-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') +-- elseif luasnip.expand_or_jumpable() then +-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-expand-or-jump', true, true, true), '') +-- else +-- fallback() +-- end +-- end, +-- [''] = function(fallback) +-- if vim.fn.pumvisible() == 1 then +-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') +-- elseif luasnip.jumpable(-1) then +-- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-jump-prev', true, true, true), '') +-- else +-- fallback() +-- end +-- end, +-- }, + -- sources = { + -- { name = 'nvim_lsp' }, + -- { name = 'luasnip' }, + -- }, +-- } +-------------------- NVIM-TREE ----------------------------- +g.nvim_tree_auto_open = 1 +-------------------- NVIM-COMMENT -------------------------- +require('nvim_comment').setup() +require('nvim_comment').setup({line_mapping = '', operator_mapping = ''}) +utils.map('n', '', 'gcc') +utils.map('v', '', 'gc') diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua new file mode 100644 index 0000000..bf2d9b8 --- /dev/null +++ b/lua/cmp_plug.lua @@ -0,0 +1,93 @@ +local cmp = require('cmp') + +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.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.Insert, + select = true + }), + [""] = cmp.mapping(function(fallback) + if vim.fn.pumvisible() == 1 then + if vim.fn["UltiSnips#CanExpandSnippet"]() == 1 or + vim.fn["UltiSnips#CanJumpForwards"]() == 1 then + return vim.fn.feedkeys(t( + "=UltiSnips#ExpandSnippetOrJump()")) + end + + vim.fn.feedkeys(t(""), "n") + elseif check_back_space() then + vim.fn.feedkeys(t(""), "n") + else + fallback() + end + end, {"i", "s"}), + [""] = cmp.mapping(function(fallback) + if vim.fn.pumvisible() == 1 then + vim.fn.feedkeys(t(""), "n") + else + fallback() + end + end, {"i", "s"}) + }, + snippet = {expand = function(args) vim.fn["UltiSnips#Anon"](args.body) end}, + sources = { + {name = 'buffer'}, {name = 'nvim_lsp'}, {name = "ultisnips"}, + {name = "nvim_lua"}, {name = "look"}, {name = "path"}, + {name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"}, + {name = "emoji"} + }, + completion = {completeopt = 'menu,menuone,noinsert'} +} + +-- Autopairs +--require("nvim-autopairs.completion.cmp").setup({ +-- map_cr = true, +-- map_complete = true, +-- auto_select = true +--}) + +-- 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/keymappings.lua b/lua/keymappings.lua index b367f5e..4a8ebc3 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -11,6 +11,20 @@ utils.map('v', 'y', '"+y') utils.map('n', 'Y', '"+yg_') utils.map('n', 'y', '"+y') utils.map('n', 'yy', '"+yy') --- Tabs and Split -utils.map('n', 'F2', ':tabnew .') +-- Tabs +utils.map('n', '', ':tabnew .') +utils.map('i', '', ':tabnew .') +utils.map('n', '', 'gt') +utils.map('n', '', 'gT') +-- Split movement +utils.map('n', '', ':wincmd k') +utils.map('n', '', ':wincmd j') +utils.map('n', '', ':wincmd h') +utils.map('n', '', ':wincmd l') +-- Open a new vertical split window with Ctrl - F2 +utils.map('n', '', ':vsplit .') +utils.map('i', '', ':vsplit .') +-- Open a new horizontal split window with Shift - F2 +utils.map('n', '', ':split .') +utils.map('i', '', ':split .') diff --git a/lua/plugins.lua b/lua/plugins.lua index 068bb39..4aa41a6 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -13,4 +13,19 @@ return require('packer').startup(function() use {'nvim-lua/plenary.nvim'} use {'lewis6991/gitsigns.nvim'} use {'kosayoda/nvim-lightbulb'} + use { + 'kyazdani42/nvim-tree.lua', + requires = 'kyazdani42/nvim-web-devicons' + } + use {'terrortylor/nvim-comment'} + use { + 'hrsh7th/nvim-cmp', + requires = { + 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp', + 'quangnguyen30192/cmp-nvim-ultisnips', 'hrsh7th/cmp-nvim-lua', + 'octaltree/cmp-look', 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc', + 'f3fora/cmp-spell', 'hrsh7th/cmp-emoji' + } + } + use {'onsails/lspkind-nvim'} end) From bf40b73417a4d018102e172ef068b9dacbff39a1 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 00:26:01 +0200 Subject: [PATCH 004/114] More telescope keys --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 1e2b018..28259f3 100644 --- a/init.lua +++ b/init.lua @@ -75,6 +75,7 @@ utils.map('n', 'o', 'Telescope oldfiles') utils.map('n', 'h', 'Telescope command_history') utils.map('n', '', 'Telescope commands') utils.map('n', 'fb', 'Telescope buffers') +utils.map('n', '', 'Telescope lsp_document_symbols') -------------------- LSP ----------------------------------- local lsp = require 'lspconfig' From a413b1592cd0f3aa1d872985f05360d180a627e0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 13:07:41 +0200 Subject: [PATCH 005/114] Removed commented lines --- init.lua | 69 -------------------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/init.lua b/init.lua index 28259f3..c9f39f7 100644 --- a/init.lua +++ b/init.lua @@ -100,75 +100,6 @@ utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') require('nvim-lightbulb').update_lightbulb() -------------------- CMP ----------------------------------- require('cmp_plug') --- local cmp = require'cmp' --- cmp.setup({ --- snippet = { --- expand = function(args) --- vim.fn["vsnip#anonymous"](args.body) --- end, --- }, --- mapping = { --- [''] = cmp.mapping.confirm({ select = true }), --- }, --- sources = { --- { name = '...' }, --- ... --- } --- }) --- local cmp = require 'cmp' --- local types = require('cmp.types') --- cmp.setup { --- completion = { --- autocomplete = { --- types.cmp.TriggerEvent.TextChanged, --- }, --- completeopt = 'menu,menuone,noselect', --- keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]], --- keyword_length = 1, --- get_trigger_characters = function(trigger_characters) --- return trigger_characters --- end --- }, --- snippet = { --- expand = function(args) --- require('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 vim.fn.pumvisible() == 1 then --- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') --- elseif luasnip.expand_or_jumpable() then --- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-expand-or-jump', true, true, true), '') --- else --- fallback() --- end --- end, --- [''] = function(fallback) --- if vim.fn.pumvisible() == 1 then --- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n') --- elseif luasnip.jumpable(-1) then --- vim.fn.feedkeys(vim.api.nvim_replace_termcodes('luasnip-jump-prev', true, true, true), '') --- else --- fallback() --- end --- end, --- }, - -- sources = { - -- { name = 'nvim_lsp' }, - -- { name = 'luasnip' }, - -- }, --- } -------------------- NVIM-TREE ----------------------------- g.nvim_tree_auto_open = 1 -------------------- NVIM-COMMENT -------------------------- From 097f1a3003b5d54f61e61fa82fc5357bcdf8012b Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 13:07:54 +0200 Subject: [PATCH 006/114] Added cmake plugin --- init.lua | 3 +++ lua/plugins.lua | 3 +++ 2 files changed, 6 insertions(+) diff --git a/init.lua b/init.lua index c9f39f7..56d705e 100644 --- a/init.lua +++ b/init.lua @@ -107,3 +107,6 @@ require('nvim_comment').setup() require('nvim_comment').setup({line_mapping = '', operator_mapping = ''}) utils.map('n', '', 'gcc') utils.map('v', '', 'gc') +-------------------- CMAKE --------------------------------- +require('telescope').load_extension('cmake') +g.cmake_build_dir = '{cwd}/build_nvim' diff --git a/lua/plugins.lua b/lua/plugins.lua index 4aa41a6..20c1d91 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -28,4 +28,7 @@ return require('packer').startup(function() } } use {'onsails/lspkind-nvim'} + use {'Shatur/neovim-cmake', + requires = {'mfussenegger/nvim-dap', 'skywind3000/asyncrun.vim'} + } end) From 745ab8d4f62b14ce7e15500975f1802f3ef2747c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 13:08:07 +0200 Subject: [PATCH 007/114] Set language to US --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 56d705e..fbd219d 100644 --- a/init.lua +++ b/init.lua @@ -27,6 +27,7 @@ require('keymappings') cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme here cmd 'syntax enable' cmd 'filetype plugin indent on' +cmd 'language en_US' utils.opt('o', 'swapfile', false) utils.opt('o', 'backup', false) utils.opt('o', 'spelllang', 'en,de') From eba90135433125158eb478b258a3a2d31163261b Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 13:08:20 +0200 Subject: [PATCH 008/114] Buffer list with leader + b --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index fbd219d..7d3d198 100644 --- a/init.lua +++ b/init.lua @@ -75,7 +75,7 @@ utils.map('n', 'g', 'Telescope git_files') utils.map('n', 'o', 'Telescope oldfiles') utils.map('n', 'h', 'Telescope command_history') utils.map('n', '', 'Telescope commands') -utils.map('n', 'fb', 'Telescope buffers') +utils.map('n', 'b', 'Telescope buffers') utils.map('n', '', 'Telescope lsp_document_symbols') -------------------- LSP ----------------------------------- local lsp = require 'lspconfig' From b216167c31b02ede6ca1de0d6f18ad4b7a88e8b9 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 14:03:58 +0200 Subject: [PATCH 009/114] Some additional keys --- init.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 7d3d198..d0e5008 100644 --- a/init.lua +++ b/init.lua @@ -76,6 +76,7 @@ utils.map('n', 'o', 'Telescope oldfiles') utils.map('n', 'h', 'Telescope command_history') utils.map('n', '', 'Telescope commands') utils.map('n', 'b', 'Telescope buffers') +utils.map('n', 'r', 'Telescope lsp_references') utils.map('n', '', 'Telescope lsp_document_symbols') -------------------- LSP ----------------------------------- local lsp = require 'lspconfig' @@ -89,12 +90,15 @@ utils.map('n', ',', 'lua vim.lsp.diagnostic.goto_prev()') utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()') utils.map('n', 'a', 'lua vim.lsp.buf.code_action()') utils.map('n', 'd', 'lua vim.lsp.buf.definition()') +utils.map('n', 'e', 'lua vim.lsp.buf.declaration()') utils.map('n', 'f', 'lua vim.lsp.buf.formatting()') utils.map('n', 'h', 'lua vim.lsp.buf.hover()') utils.map('n', 'm', 'lua vim.lsp.buf.rename()') -utils.map('n', 'r', 'lua vim.lsp.buf.references()') +-- utils.map('n', 'r', 'lua vim.lsp.buf.references()') utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') +utils.map('n', '', ':ClangdSwitchSourceHeader') + -------------------- GITSIGNS ------------------------------ -- require('gitsigns').setup() -------------------- LIGHTBULB ----------------------------- @@ -111,3 +115,4 @@ utils.map('v', '', 'gc') -------------------- CMAKE --------------------------------- require('telescope').load_extension('cmake') g.cmake_build_dir = '{cwd}/build_nvim' +utils.map('n', '', ':CMake build:copen') From e5307b9a1e66352455765859ce8661358436a22c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 14:04:08 +0200 Subject: [PATCH 010/114] Sorting: LSP first --- lua/cmp_plug.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua index bf2d9b8..5fad150 100644 --- a/lua/cmp_plug.lua +++ b/lua/cmp_plug.lua @@ -68,7 +68,7 @@ cmp.setup { }, snippet = {expand = function(args) vim.fn["UltiSnips#Anon"](args.body) end}, sources = { - {name = 'buffer'}, {name = 'nvim_lsp'}, {name = "ultisnips"}, + {name = 'nvim_lsp'}, {name = 'buffer'}, {name = "ultisnips"}, {name = "nvim_lua"}, {name = "look"}, {name = "path"}, {name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"}, {name = "emoji"} From a75de0092ad93a64e90dc54aef33ac367630e3aa Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 14:04:19 +0200 Subject: [PATCH 011/114] More keys --- lua/keymappings.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 4a8ebc3..1c69c98 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -23,8 +23,13 @@ utils.map('n', '', ':wincmd j') utils.map('n', '', ':wincmd h') utils.map('n', '', ':wincmd l') -- Open a new vertical split window with Ctrl - F2 -utils.map('n', '', ':vsplit .') +utils.map('n', '', ':vsplit .') utils.map('i', '', ':vsplit .') -- Open a new horizontal split window with Shift - F2 -utils.map('n', '', ':split .') +utils.map('n', '', ':split .') utils.map('i', '', ':split .') + + +utils.map('n', '', ':wa') + +utils.map('n', '', '') From 9074078a9863b5f2f3a07d5bf012f3a0a9027a93 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 19:13:26 +0200 Subject: [PATCH 012/114] Added neoclip and lualine --- init.lua | 6 ++++++ lua/plugins.lua | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/init.lua b/init.lua index d0e5008..8d57e3f 100644 --- a/init.lua +++ b/init.lua @@ -96,6 +96,7 @@ utils.map('n', 'h', 'lua vim.lsp.buf.hover()') utils.map('n', 'm', 'lua vim.lsp.buf.rename()') -- utils.map('n', 'r', 'lua vim.lsp.buf.references()') utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') +utils.map('n', '', 'lua vim.lsp.buf.workspace_symbol()') utils.map('n', '', ':ClangdSwitchSourceHeader') @@ -116,3 +117,8 @@ utils.map('v', '', 'gc') require('telescope').load_extension('cmake') g.cmake_build_dir = '{cwd}/build_nvim' utils.map('n', '', ':CMake build:copen') +-------------------- NEOCLIP ------------------------------- +require('neoclip').setup() +require('telescope').load_extension('neoclip') +-------------------- LUALINE ------------------------------- +require('lualine').setup() diff --git a/lua/plugins.lua b/lua/plugins.lua index 20c1d91..3c0dafd 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -31,4 +31,9 @@ return require('packer').startup(function() use {'Shatur/neovim-cmake', requires = {'mfussenegger/nvim-dap', 'skywind3000/asyncrun.vim'} } + use {'AckslD/nvim-neoclip.lua'} + use { + 'hoob3rt/lualine.nvim', + requires = {'kyazdani42/nvim-web-devicons', opt = true} + } end) From f464972ef0e3562a00801fc0bee96fd7db23d242 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 20:27:11 +0200 Subject: [PATCH 013/114] Added lsp-rooter and ts-rainbow --- init.lua | 12 ++++++++++++ lua/plugins.lua | 2 ++ 2 files changed, 14 insertions(+) diff --git a/init.lua b/init.lua index 8d57e3f..a919816 100644 --- a/init.lua +++ b/init.lua @@ -122,3 +122,15 @@ require('neoclip').setup() require('telescope').load_extension('neoclip') -------------------- LUALINE ------------------------------- require('lualine').setup() +-------------------- LSP-ROOTER ---------------------------- +require("lsp-rooter").setup { } +-------------------- 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 + } +} diff --git a/lua/plugins.lua b/lua/plugins.lua index 3c0dafd..4969785 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -36,4 +36,6 @@ return require('packer').startup(function() 'hoob3rt/lualine.nvim', requires = {'kyazdani42/nvim-web-devicons', opt = true} } + use {'ahmedkhalf/lsp-rooter.nvim'} + use {'p00f/nvim-ts-rainbow'} end) From 4ae9b84097c6f7a936f9e597fcbe1d3d675bcc84 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 20:27:26 +0200 Subject: [PATCH 014/114] nvimtree config --- init.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/init.lua b/init.lua index a919816..35ba79f 100644 --- a/init.lua +++ b/init.lua @@ -108,6 +108,10 @@ require('nvim-lightbulb').update_lightbulb() require('cmp_plug') -------------------- NVIM-TREE ----------------------------- g.nvim_tree_auto_open = 1 +-- g.nvim_tree_show_icons = { 'git': 1, 'folders': 1, 'files': 1, 'folder_arrows': 1 } +utils.map('n', 'tt', 'NvimTreeToggle') +g.nvim_tree_follow = 1 +g.nvim_tree_highlight_opened_files = 1 -------------------- NVIM-COMMENT -------------------------- require('nvim_comment').setup() require('nvim_comment').setup({line_mapping = '', operator_mapping = ''}) From f71bb836a22d7ce6e0eb2da6dd59647da4fafd18 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 20:27:49 +0200 Subject: [PATCH 015/114] Remove wrong vim cmd --- init.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/init.lua b/init.lua index 35ba79f..bd180ca 100644 --- a/init.lua +++ b/init.lua @@ -13,12 +13,6 @@ if fn.empty(fn.glob(install_path)) > 0 then vim.cmd 'packadd packer.nvim' end vim.cmd [[packadd packer.nvim]] -vim.cmd([[ - augroup packer_user_config - autocmd! - autocmd BufWritePost plugins.lua source | PackerCompile - augroup end -]]) local utils = require('utils') -- Install plugins require('plugins') From 9009d1365fbc0c913f8ed97843c1595697dd4fce Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 21:32:53 +0200 Subject: [PATCH 016/114] Try to use luasnip with cmp --- lua/cmp_plug.lua | 8 ++++++-- lua/plugins.lua | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua index 5fad150..767e9ad 100644 --- a/lua/cmp_plug.lua +++ b/lua/cmp_plug.lua @@ -66,9 +66,13 @@ cmp.setup { end end, {"i", "s"}) }, - snippet = {expand = function(args) vim.fn["UltiSnips#Anon"](args.body) end}, + snippet = { + expand = function(args) + require'luasnip'.lsp_expand(args.body) + end + }, sources = { - {name = 'nvim_lsp'}, {name = 'buffer'}, {name = "ultisnips"}, + {name = 'nvim_lsp'}, {name = 'buffer'}, {name = "luasnip"}, {name = "nvim_lua"}, {name = "look"}, {name = "path"}, {name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"}, {name = "emoji"} diff --git a/lua/plugins.lua b/lua/plugins.lua index 4969785..b77226d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -22,11 +22,12 @@ return require('packer').startup(function() 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp', - 'quangnguyen30192/cmp-nvim-ultisnips', 'hrsh7th/cmp-nvim-lua', + 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-nvim-lua', 'octaltree/cmp-look', 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc', 'f3fora/cmp-spell', 'hrsh7th/cmp-emoji' } } + use {'rafamadriz/friendly-snippets'} use {'onsails/lspkind-nvim'} use {'Shatur/neovim-cmake', requires = {'mfussenegger/nvim-dap', 'skywind3000/asyncrun.vim'} From 19f925775a04dde24b7f30cb2ecf20643670d248 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 9 Sep 2021 22:23:07 +0200 Subject: [PATCH 017/114] Get snippets running --- init.lua | 37 +++++++++++++++++++++++++++++++++---- lua/cmp_plug.lua | 33 ++++++++++++++++++--------------- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/init.lua b/init.lua index bd180ca..275eed3 100644 --- a/init.lua +++ b/init.lua @@ -73,12 +73,12 @@ utils.map('n', 'b', 'Telescope buffers') utils.map('n', 'r', 'Telescope lsp_references') utils.map('n', '', 'Telescope lsp_document_symbols') -------------------- LSP ----------------------------------- -local lsp = require 'lspconfig' +local nvim_lsp = require 'lspconfig' -- We use the default settings for ccls and pylsp: the option table can stay empty -lsp.ccls.setup {} -lsp.pyright.setup{} -lsp.clangd.setup{} +nvim_lsp.ccls.setup {} +nvim_lsp.pyright.setup{} +nvim_lsp.clangd.setup{} utils.map('n', ',', 'lua vim.lsp.diagnostic.goto_prev()') utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()') @@ -94,6 +94,33 @@ utils.map('n', '', 'lua vim.lsp.buf.workspace_symbol()') utils.map('n', '', ':ClangdSwitchSourceHeader') +-- Add additional capabilities supported by nvim-cmp +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', + }, +} + +-- Enable some language servers with the additional completion capabilities offered by nvim-cmp +local servers = { 'clangd', 'pyright', 'rust_analyzer', 'tsserver' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + -- on_attach = my_custom_on_attach, + capabilities = capabilities, + } +end + -------------------- GITSIGNS ------------------------------ -- require('gitsigns').setup() -------------------- LIGHTBULB ----------------------------- @@ -132,3 +159,5 @@ require'nvim-treesitter.configs'.setup { -- termcolors = {} -- table of colour name strings } } +-------------------- LUASNIP ------------------------------- +require("luasnip.loaders.from_vscode").load() diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua index 767e9ad..502ab1f 100644 --- a/lua/cmp_plug.lua +++ b/lua/cmp_plug.lua @@ -1,4 +1,5 @@ local cmp = require('cmp') +local luasnip = require("luasnip") local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) @@ -45,26 +46,28 @@ cmp.setup { }), [""] = cmp.mapping(function(fallback) if vim.fn.pumvisible() == 1 then - if vim.fn["UltiSnips#CanExpandSnippet"]() == 1 or - vim.fn["UltiSnips#CanJumpForwards"]() == 1 then - return vim.fn.feedkeys(t( - "=UltiSnips#ExpandSnippetOrJump()")) - end - - vim.fn.feedkeys(t(""), "n") - elseif check_back_space() then - vim.fn.feedkeys(t(""), "n") + vim.api.nvim_feedkeys(t(""), "n", true) + elseif luasnip.expand_or_jumpable() then + vim.api.nvim_feedkeys(t("luasnip-expand-or-jump"), "", true) else - fallback() + fallback() end - end, {"i", "s"}), - [""] = cmp.mapping(function(fallback) + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(t(""), "n") + vim.api.nvim_feedkeys(t(""), "n", true) + elseif luasnip.jumpable(-1) then + vim.api.nvim_feedkeys(t("luasnip-jump-prev"), "", true) else - fallback() + fallback() end - end, {"i", "s"}) + end, { + "i", + "s", + }), }, snippet = { expand = function(args) From e6a86c6a3e7bdc393bf8505d7f0a858d6fe74db6 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 14:19:07 +0200 Subject: [PATCH 018/114] Replace lsp-rooter with project --- init.lua | 7 +++++-- lua/plugins.lua | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 275eed3..a3f08ac 100644 --- a/init.lua +++ b/init.lua @@ -147,8 +147,11 @@ require('neoclip').setup() require('telescope').load_extension('neoclip') -------------------- LUALINE ------------------------------- require('lualine').setup() --------------------- LSP-ROOTER ---------------------------- -require("lsp-rooter").setup { } +-------------------- PROJECT ------------------------------- + require("project_nvim").setup {} +require('telescope').load_extension('projects') +g.nvim_tree_update_cwd = 1 +g.nvim_tree_respect_buf_cwd = 1 -------------------- TS-RAINBOW ---------------------------- require'nvim-treesitter.configs'.setup { rainbow = { diff --git a/lua/plugins.lua b/lua/plugins.lua index b77226d..87ec601 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -37,6 +37,6 @@ return require('packer').startup(function() 'hoob3rt/lualine.nvim', requires = {'kyazdani42/nvim-web-devicons', opt = true} } - use {'ahmedkhalf/lsp-rooter.nvim'} + use {'ahmedkhalf/project.nvim'} use {'p00f/nvim-ts-rainbow'} end) From d83c9e46939bcdc7e6a2dbd336ee0c30405fba75 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 15:11:40 +0200 Subject: [PATCH 019/114] Changed windows font --- ginit.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ginit.vim b/ginit.vim index 2534b5a..c001d34 100644 --- a/ginit.vim +++ b/ginit.vim @@ -1,6 +1,6 @@ " set mouse=a if has("win32") - Guifont! Consolas:h10 + Guifont! Hack NF:h9 else " Guifont DejaVu Sans Mono:h10 " Guifont Liberation Mono for Powerline:h9 From a3ca5dfb24c5dff89695005425b21fb9574bd27f Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 15:12:01 +0200 Subject: [PATCH 020/114] Don't open nvim tree at start --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index a3f08ac..0cb82f7 100644 --- a/init.lua +++ b/init.lua @@ -128,7 +128,7 @@ require('nvim-lightbulb').update_lightbulb() -------------------- CMP ----------------------------------- require('cmp_plug') -------------------- NVIM-TREE ----------------------------- -g.nvim_tree_auto_open = 1 +g.nvim_tree_auto_open = 0 -- g.nvim_tree_show_icons = { 'git': 1, 'folders': 1, 'files': 1, 'folder_arrows': 1 } utils.map('n', 'tt', 'NvimTreeToggle') g.nvim_tree_follow = 1 From dee4916034c59b77947b8f616b8ab57ecd035be8 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 15:12:19 +0200 Subject: [PATCH 021/114] Show project message --- init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 0cb82f7..e88c636 100644 --- a/init.lua +++ b/init.lua @@ -148,7 +148,9 @@ require('telescope').load_extension('neoclip') -------------------- LUALINE ------------------------------- require('lualine').setup() -------------------- PROJECT ------------------------------- - require("project_nvim").setup {} +require("project_nvim").setup { + silent_chdir = false, +} require('telescope').load_extension('projects') g.nvim_tree_update_cwd = 1 g.nvim_tree_respect_buf_cwd = 1 From 1d6106db84dc63d10edf67ff2f858bca97114067 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 15:59:43 +0200 Subject: [PATCH 022/114] Fixed for nvy --- init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init.lua b/init.lua index e88c636..576aafa 100644 --- a/init.lua +++ b/init.lua @@ -22,6 +22,7 @@ cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme h cmd 'syntax enable' cmd 'filetype plugin indent on' cmd 'language en_US' +utils.opt('o', 'guifont', 'Hack NF:h9') utils.opt('o', 'swapfile', false) utils.opt('o', 'backup', false) utils.opt('o', 'spelllang', 'en,de') @@ -72,6 +73,7 @@ utils.map('n', '', 'Telescope commands') utils.map('n', 'b', 'Telescope buffers') utils.map('n', 'r', 'Telescope lsp_references') utils.map('n', '', 'Telescope lsp_document_symbols') +utils.map('n', '', 'Telescope lsp_document_symbols') -------------------- LSP ----------------------------------- local nvim_lsp = require 'lspconfig' From d353761846d2327e0759da421ab1d9fac599059c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 19:44:55 +0200 Subject: [PATCH 023/114] Use commented --- init.lua | 7 ++----- lua/plugins.lua | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 576aafa..cc44676 100644 --- a/init.lua +++ b/init.lua @@ -135,11 +135,8 @@ g.nvim_tree_auto_open = 0 utils.map('n', 'tt', 'NvimTreeToggle') g.nvim_tree_follow = 1 g.nvim_tree_highlight_opened_files = 1 --------------------- NVIM-COMMENT -------------------------- -require('nvim_comment').setup() -require('nvim_comment').setup({line_mapping = '', operator_mapping = ''}) -utils.map('n', '', 'gcc') -utils.map('v', '', 'gc') +-------------------- COMMENTED ----------------------------- +require('commented').setup() -------------------- CMAKE --------------------------------- require('telescope').load_extension('cmake') g.cmake_build_dir = '{cwd}/build_nvim' diff --git a/lua/plugins.lua b/lua/plugins.lua index 87ec601..a166c1a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -17,7 +17,7 @@ return require('packer').startup(function() 'kyazdani42/nvim-tree.lua', requires = 'kyazdani42/nvim-web-devicons' } - use {'terrortylor/nvim-comment'} + use{'winston0410/commented.nvim'} use { 'hrsh7th/nvim-cmp', requires = { From c5814a6774b4845b08233506dbdd9f5d5d07361d Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 19:45:15 +0200 Subject: [PATCH 024/114] projects keybinding --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index cc44676..ef4ee0a 100644 --- a/init.lua +++ b/init.lua @@ -153,6 +153,7 @@ require("project_nvim").setup { require('telescope').load_extension('projects') g.nvim_tree_update_cwd = 1 g.nvim_tree_respect_buf_cwd = 1 +utils.map('n', 'p', 'Telescope projects') -------------------- TS-RAINBOW ---------------------------- require'nvim-treesitter.configs'.setup { rainbow = { From 86e963c4740f1e89d1ad4612dbfa07a9f85d8ac0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 21:26:47 +0200 Subject: [PATCH 025/114] lsp highlight and some keybindings --- init.lua | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index ef4ee0a..7757a9e 100644 --- a/init.lua +++ b/init.lua @@ -49,6 +49,7 @@ 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) -- Highlight on yank vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' @@ -88,11 +89,14 @@ utils.map('n', 'a', 'lua vim.lsp.buf.code_action()') utils.map('n', 'd', 'lua vim.lsp.buf.definition()') utils.map('n', 'e', 'lua vim.lsp.buf.declaration()') utils.map('n', 'f', 'lua vim.lsp.buf.formatting()') +utils.map('v', 'f', 'lua vim.lsp.buf.formatting()') utils.map('n', 'h', 'lua vim.lsp.buf.hover()') utils.map('n', 'm', 'lua vim.lsp.buf.rename()') -- utils.map('n', 'r', 'lua vim.lsp.buf.references()') utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') utils.map('n', '', 'lua vim.lsp.buf.workspace_symbol()') +utils.map('n', 'D', 'lua vim.lsp.buf.type_definition()') +utils.map('n', '', 'lua vim.lsp.buf.signature_help()') utils.map('n', '', ':ClangdSwitchSourceHeader') @@ -114,11 +118,60 @@ capabilities.textDocument.completion.completionItem.resolveSupport = { }, } +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 } + 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.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + + -- Set some keybinds conditional on server capabilities + if client.resolved_capabilities.document_formatting then + buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) + end + if client.resolved_capabilities.document_range_formatting then + buf_set_keymap("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 +end + -- Enable some language servers with the additional completion capabilities offered by nvim-cmp local servers = { 'clangd', 'pyright', 'rust_analyzer', 'tsserver' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { - -- on_attach = my_custom_on_attach, + on_attach = on_attach, capabilities = capabilities, } end From 8d6d4b5c738e2407cc7b66e19d6e01ff7ea2e671 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 23:46:00 +0200 Subject: [PATCH 026/114] Own configuration file for lsp and some small fixes --- init.lua | 102 ++------------------------------------------ lua/keymappings.lua | 2 +- lua/mylsp.lua | 82 +++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 100 deletions(-) create mode 100644 lua/mylsp.lua diff --git a/init.lua b/init.lua index 7757a9e..a126cd5 100644 --- a/init.lua +++ b/init.lua @@ -75,111 +75,15 @@ utils.map('n', 'b', 'Telescope buffers') 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 lsp_document_diagnostics') -------------------- LSP ----------------------------------- -local nvim_lsp = require 'lspconfig' - --- We use the default settings for ccls and pylsp: the option table can stay empty -nvim_lsp.ccls.setup {} -nvim_lsp.pyright.setup{} -nvim_lsp.clangd.setup{} - -utils.map('n', ',', 'lua vim.lsp.diagnostic.goto_prev()') -utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()') -utils.map('n', 'a', 'lua vim.lsp.buf.code_action()') -utils.map('n', 'd', 'lua vim.lsp.buf.definition()') -utils.map('n', 'e', 'lua vim.lsp.buf.declaration()') -utils.map('n', 'f', 'lua vim.lsp.buf.formatting()') -utils.map('v', 'f', 'lua vim.lsp.buf.formatting()') -utils.map('n', 'h', 'lua vim.lsp.buf.hover()') -utils.map('n', 'm', 'lua vim.lsp.buf.rename()') --- utils.map('n', 'r', 'lua vim.lsp.buf.references()') -utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') -utils.map('n', '', 'lua vim.lsp.buf.workspace_symbol()') -utils.map('n', 'D', 'lua vim.lsp.buf.type_definition()') -utils.map('n', '', 'lua vim.lsp.buf.signature_help()') - -utils.map('n', '', ':ClangdSwitchSourceHeader') - --- Add additional capabilities supported by nvim-cmp -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 } - 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.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) - - -- Set some keybinds conditional on server capabilities - if client.resolved_capabilities.document_formatting then - buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) - end - if client.resolved_capabilities.document_range_formatting then - buf_set_keymap("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 -end - --- Enable some language servers with the additional completion capabilities offered by nvim-cmp -local servers = { 'clangd', 'pyright', 'rust_analyzer', 'tsserver' } -for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - on_attach = on_attach, - capabilities = capabilities, - } -end +require('mylsp') -------------------- GITSIGNS ------------------------------ -- require('gitsigns').setup() -------------------- LIGHTBULB ----------------------------- require('nvim-lightbulb').update_lightbulb() +vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()]] -------------------- CMP ----------------------------------- require('cmp_plug') -------------------- NVIM-TREE ----------------------------- diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 1c69c98..545d995 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -32,4 +32,4 @@ utils.map('i', '', ':split .') utils.map('n', '', ':wa') -utils.map('n', '', '') + diff --git a/lua/mylsp.lua b/lua/mylsp.lua new file mode 100644 index 0000000..15433fc --- /dev/null +++ b/lua/mylsp.lua @@ -0,0 +1,82 @@ +local nvim_lsp = require 'lspconfig' +local utils = require('utils') + +-- We use the default settings for ccls and pylsp: the option table can stay empty +nvim_lsp.ccls.setup {} +nvim_lsp.pyright.setup{} +nvim_lsp.clangd.setup{} + + +-- Add additional capabilities supported by nvim-cmp +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()') + utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()') + utils.map('n', 'a', 'lua vim.lsp.buf.code_action()') + utils.map('n', 'd', 'lua vim.lsp.buf.definition()') + utils.map('n', 'e', 'lua vim.lsp.buf.declaration()') + utils.map('n', 'h', 'lua vim.lsp.buf.hover()') + utils.map('n', 'm', 'lua vim.lsp.buf.rename()') + -- utils.map('n', 'r', 'lua vim.lsp.buf.references()') + utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') + utils.map('n', '', 'lua vim.lsp.buf.workspace_symbol()') + utils.map('n', 'D', 'lua vim.lsp.buf.type_definition()') + utils.map('n', '', 'lua vim.lsp.buf.signature_help()') + + utils.map('n', '', ':ClangdSwitchSourceHeader') + + -- Set some keybinds conditional on server capabilities + if client.resolved_capabilities.document_formatting then + utils.map('n', 'f', 'lua vim.lsp.buf.formatting()') + end + if client.resolved_capabilities.document_range_formatting then + utils.map('v', 'f', 'lua vim.lsp.buf.range_formatting()') + 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 +end + +-- Enable some language servers with the additional completion capabilities offered by nvim-cmp +local servers = { 'clangd', 'pyright', 'rust_analyzer', 'tsserver' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end From f9795280f5d3fe77c2869edccf8109c9030e0362 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 10 Sep 2021 23:54:38 +0200 Subject: [PATCH 027/114] Configure cmake lsp --- lua/mylsp.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 15433fc..de49ca7 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -5,6 +5,7 @@ local utils = require('utils') nvim_lsp.ccls.setup {} nvim_lsp.pyright.setup{} nvim_lsp.clangd.setup{} +nvim_lsp.cmake.setup{} -- Add additional capabilities supported by nvim-cmp @@ -73,7 +74,7 @@ local on_attach = function(client, bufnr) end -- Enable some language servers with the additional completion capabilities offered by nvim-cmp -local servers = { 'clangd', 'pyright', 'rust_analyzer', 'tsserver' } +local servers = { 'clangd', 'pyright', 'cmake', 'tsserver' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach, From 3789e6736d0984e309c98e20dd8bf140b7fe35c2 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 11 Sep 2021 00:21:26 +0200 Subject: [PATCH 028/114] json lsp --- lua/mylsp.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index de49ca7..934b97a 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -6,6 +6,7 @@ nvim_lsp.ccls.setup {} nvim_lsp.pyright.setup{} nvim_lsp.clangd.setup{} nvim_lsp.cmake.setup{} +nvim_lsp.jsonls.setup{} -- Add additional capabilities supported by nvim-cmp @@ -74,7 +75,7 @@ local on_attach = function(client, bufnr) end -- Enable some language servers with the additional completion capabilities offered by nvim-cmp -local servers = { 'clangd', 'pyright', 'cmake', 'tsserver' } +local servers = { 'clangd', 'pyright', 'cmake', 'jsonls' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach, From 4ea2b963326e6d8c617f061b3adc9efb11c3207a Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 11 Sep 2021 00:21:34 +0200 Subject: [PATCH 029/114] outline plugin --- lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index a166c1a..e1f5277 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -39,4 +39,5 @@ return require('packer').startup(function() } use {'ahmedkhalf/project.nvim'} use {'p00f/nvim-ts-rainbow'} + use {'simrat39/symbols-outline.nvim'} end) From afdb7872571835ca0913e1cf112fdb2c4fb58657 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 11 Sep 2021 12:40:16 +0200 Subject: [PATCH 030/114] Setup line wrapping --- init.lua | 1 + lua/keymappings.lua | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/init.lua b/init.lua index a126cd5..ca6f6ba 100644 --- a/init.lua +++ b/init.lua @@ -50,6 +50,7 @@ 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) -- Highlight on yank vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 545d995..321ac18 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -33,3 +33,20 @@ utils.map('i', '', ':split .') 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') From d97a5cbd1158c9d28b77df04aae30652a7d0f40c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 12 Sep 2021 20:25:50 +0200 Subject: [PATCH 031/114] autocommands --- init.lua | 5 ++--- lua/autocommands.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 lua/autocommands.lua diff --git a/init.lua b/init.lua index ca6f6ba..d59acdc 100644 --- a/init.lua +++ b/init.lua @@ -52,9 +52,8 @@ utils.opt('o', 'list', true) utils.opt('o', 'updatetime', 300) utils.opt('o', 'wrap', true) --- Highlight on yank -vim.cmd 'au TextYankPost * lua vim.highlight.on_yank {on_visual = false}' - +-------------------- AUTOCOMMANDS -------------------------- +require("autocommands") -------------------- MAPPINGS ------------------------------ -- to navigate the completion menu utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) diff --git a/lua/autocommands.lua b/lua/autocommands.lua new file mode 100644 index 0000000..d017d18 --- /dev/null +++ b/lua/autocommands.lua @@ -0,0 +1,48 @@ +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 = { + change_header = { + {'BufWritePre', '*', 'lua changeheader()'} + }; + packer = { + { 'BufWritePost', 'plugins.lua', 'PackerCompile' }; + }; + restore_cursor = { + { 'BufRead', '*', [[call setpos(".", getpos("'\""))]] }; + }; + save_shada = { + {'VimLeave', '*', 'wshada!'}; + }; + resize_windows_proportionally = { + { 'VimResized', '*', ':wincmd =' }; + }; + toggle_search_highlighting = { + { 'InsertEnter', '*', 'setlocal nohlsearch' }; + }; + lua_highlight = { + { 'TextYankPost', '*', [[silent! lua vim.highlight.on_yank() {higroup='IncSearch', timeout=400}]] }; + }; + ansi_esc_log = { + { 'BufEnter', '*.log', ':AnsiEsc' }; + }; + 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'} + } +} + +nvim_create_augroups(autocmds) + From dd964288285e71ed20db65e3c645608a1266e75a Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 12 Sep 2021 20:26:04 +0200 Subject: [PATCH 032/114] Show matching braces --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index d59acdc..bc12e7d 100644 --- a/init.lua +++ b/init.lua @@ -51,6 +51,7 @@ 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) -------------------- AUTOCOMMANDS -------------------------- require("autocommands") From ba1fd529d5588d82ebee3923b389e4471001cf0b Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 12 Sep 2021 20:26:24 +0200 Subject: [PATCH 033/114] Command history in v mode --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index bc12e7d..041def4 100644 --- a/init.lua +++ b/init.lua @@ -71,6 +71,7 @@ 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', 'r', 'Telescope lsp_references') From 2812ea2b2b0c6b1da9a88430642d719cfa9363d0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 12 Sep 2021 20:54:16 +0200 Subject: [PATCH 034/114] Highlight word under cursor --- lua/keymappings.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 321ac18..98ed691 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -50,3 +50,6 @@ utils.map('v', '', 'gk') utils.map('v', '', 'gj') utils.map('v', '', 'g') utils.map('v', '', 'g') + +-- Highlight word under cursor +utils.map('n', 'ü', ":exec 'match Search /\\V\\<' . expand('') . '\\>/'") From cb972476a76f52a8ce846771b877552d3ef8681e Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 12 Sep 2021 20:54:33 +0200 Subject: [PATCH 035/114] Indent without losing v --- lua/keymappings.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 98ed691..bd1a8c0 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -29,10 +29,8 @@ utils.map('i', '', ':vsplit .') utils.map('n', '', ':split .') utils.map('i', '', ':split .') - utils.map('n', '', ':wa') - -- Linewrap and jumping utils.map('n', 'k', 'gk') utils.map('n', 'j', 'gj') @@ -51,5 +49,8 @@ utils.map('v', '', 'gj') utils.map('v', '', 'g') utils.map('v', '', 'g') +utils.map('v', '<', '', '>gv') + -- Highlight word under cursor utils.map('n', 'ü', ":exec 'match Search /\\V\\<' . expand('') . '\\>/'") From ccade921f970ad38ae7b53c193718dcd34f96013 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 12 Sep 2021 20:54:43 +0200 Subject: [PATCH 036/114] Fixed save --- lua/autocommands.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index d017d18..7447c9d 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -11,9 +11,6 @@ function nvim_create_augroups(definitions) end local autocmds = { - change_header = { - {'BufWritePre', '*', 'lua changeheader()'} - }; packer = { { 'BufWritePost', 'plugins.lua', 'PackerCompile' }; }; From 9b0dc1fe0613f9ac49e4143fa53a94330fc6f6cc Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 12 Sep 2021 20:54:54 +0200 Subject: [PATCH 037/114] Set filetypes for some files --- lua/autocommands.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 7447c9d..0a65ce8 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -34,10 +34,10 @@ local autocmds = { }; 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'} + {'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'}; } } From 51b5950376373044eaa6d88ae6e4d245634ac3f7 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 12 Sep 2021 20:58:05 +0200 Subject: [PATCH 038/114] ignore plugin/packer_compiled.lua --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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 From 3cd0e65444a4af3aabe1656bf5b40aa11f835475 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Mon, 13 Sep 2021 00:18:22 +0200 Subject: [PATCH 039/114] Added bufferline --- init.lua | 2 ++ lua/keymappings.lua | 4 ++-- lua/plugins.lua | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 041def4..184ad37 100644 --- a/init.lua +++ b/init.lua @@ -125,3 +125,5 @@ require'nvim-treesitter.configs'.setup { } -------------------- LUASNIP ------------------------------- require("luasnip.loaders.from_vscode").load() +-------------------- BUFFERLINE ---------------------------- +require("bufferline").setup{} diff --git a/lua/keymappings.lua b/lua/keymappings.lua index bd1a8c0..583fdb6 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -15,8 +15,8 @@ utils.map('n', 'yy', '"+yy') -- Tabs utils.map('n', '', ':tabnew .') utils.map('i', '', ':tabnew .') -utils.map('n', '', 'gt') -utils.map('n', '', 'gT') +utils.map('n', '', ':BufferLineCycleNext') +utils.map('n', '', ':BufferLineCyclePrev') -- Split movement utils.map('n', '', ':wincmd k') utils.map('n', '', ':wincmd j') diff --git a/lua/plugins.lua b/lua/plugins.lua index e1f5277..01b00fb 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -40,4 +40,8 @@ return require('packer').startup(function() use {'ahmedkhalf/project.nvim'} use {'p00f/nvim-ts-rainbow'} use {'simrat39/symbols-outline.nvim'} + use { + 'akinsho/bufferline.nvim', + requires = 'kyazdani42/nvim-web-devicons' + } end) From 71e9004cee01702531579ff743febd5dbc674fa9 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Mon, 13 Sep 2021 00:18:55 +0200 Subject: [PATCH 040/114] Some lsp keys --- lua/mylsp.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 934b97a..6d84591 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -37,14 +37,16 @@ local on_attach = function(client, bufnr) local opts = { noremap=true, silent=true } utils.map('n', ',', 'lua vim.lsp.diagnostic.goto_prev()') utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()') - utils.map('n', 'a', 'lua vim.lsp.buf.code_action()') + utils.map('n', 'a', 'Telescope lsp_code_actions') utils.map('n', 'd', 'lua vim.lsp.buf.definition()') utils.map('n', 'e', 'lua vim.lsp.buf.declaration()') utils.map('n', 'h', 'lua vim.lsp.buf.hover()') + utils.map('n', 'c', 'lua vim.lsp.buf.outgoing_calls()') + utils.map('n', 'C', 'lua vim.lsp.buf.incoming_calls()') utils.map('n', 'm', 'lua vim.lsp.buf.rename()') -- utils.map('n', 'r', 'lua vim.lsp.buf.references()') utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') - utils.map('n', '', 'lua vim.lsp.buf.workspace_symbol()') + utils.map('n', '', 'Telescope lsp_dynamic_workspace_symbols') utils.map('n', 'D', 'lua vim.lsp.buf.type_definition()') utils.map('n', '', 'lua vim.lsp.buf.signature_help()') From 0367479622f22824095e6b6db987eac9928a3577 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Mon, 13 Sep 2021 00:39:16 +0200 Subject: [PATCH 041/114] Added git blame plugin --- lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 01b00fb..2ea31a4 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -44,4 +44,5 @@ return require('packer').startup(function() 'akinsho/bufferline.nvim', requires = 'kyazdani42/nvim-web-devicons' } + use {'f-person/git-blame.nvim'} end) From 82f544a1f5044fd0d0a65a8ee8651ec476fedf5c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 15 Sep 2021 00:26:31 +0200 Subject: [PATCH 042/114] =?UTF-8?q?Fix=20the=20=C3=BC=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 1 + lua/autocommands.lua | 3 --- lua/keymappings.lua | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 184ad37..445ca57 100644 --- a/init.lua +++ b/init.lua @@ -22,6 +22,7 @@ cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme h cmd 'syntax enable' cmd 'filetype plugin indent on' cmd 'language en_US' +utils.opt('o', 'hlsearch', true) utils.opt('o', 'guifont', 'Hack NF:h9') utils.opt('o', 'swapfile', false) utils.opt('o', 'backup', false) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 0a65ce8..ef21744 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -23,9 +23,6 @@ local autocmds = { resize_windows_proportionally = { { 'VimResized', '*', ':wincmd =' }; }; - toggle_search_highlighting = { - { 'InsertEnter', '*', 'setlocal nohlsearch' }; - }; lua_highlight = { { 'TextYankPost', '*', [[silent! lua vim.highlight.on_yank() {higroup='IncSearch', timeout=400}]] }; }; diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 583fdb6..8609e0d 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -53,4 +53,5 @@ utils.map('v', '<', '', '>gv') -- Highlight word under cursor -utils.map('n', 'ü', ":exec 'match Search /\\V\\<' . expand('') . '\\>/'") +utils.map('n', 'ü', ":let @/='\\<=expand(\"\")\\>':set hls") +utils.map('v', 'ü', "y:let @/='=escape(@\",'/\\')':set hls") From ea64556fa0fe7e64ed3a49d59bc254e9a897c35a Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 15 Sep 2021 08:23:56 +0200 Subject: [PATCH 043/114] Close buffer keymap --- lua/keymappings.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 8609e0d..ac2a8da 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -55,3 +55,6 @@ utils.map('v', '>', '>gv') -- Highlight word under cursor utils.map('n', 'ü', ":let @/='\\<=expand(\"\")\\>':set hls") utils.map('v', 'ü', "y:let @/='=escape(@\",'/\\')':set hls") + +-- Close Buffer +utils.map('n', '', ':bd') From 809dbf97d002d9bbac884b86d654601677b5fd04 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 15 Sep 2021 09:40:17 +0200 Subject: [PATCH 044/114] nvim_tree_respect_buf_cwd options seems to be buggy --- init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/init.lua b/init.lua index 445ca57..8d9e7d2 100644 --- a/init.lua +++ b/init.lua @@ -112,7 +112,6 @@ require("project_nvim").setup { } require('telescope').load_extension('projects') g.nvim_tree_update_cwd = 1 -g.nvim_tree_respect_buf_cwd = 1 utils.map('n', 'p', 'Telescope projects') -------------------- TS-RAINBOW ---------------------------- require'nvim-treesitter.configs'.setup { From b9ee58e2ecb44db3b782c1cc9cdab3a83eb91fc5 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 09:51:50 +0200 Subject: [PATCH 045/114] Disable bufferline --- init.lua | 2 -- lua/plugins.lua | 4 ---- 2 files changed, 6 deletions(-) diff --git a/init.lua b/init.lua index 8d9e7d2..c14f693 100644 --- a/init.lua +++ b/init.lua @@ -125,5 +125,3 @@ require'nvim-treesitter.configs'.setup { } -------------------- LUASNIP ------------------------------- require("luasnip.loaders.from_vscode").load() --------------------- BUFFERLINE ---------------------------- -require("bufferline").setup{} diff --git a/lua/plugins.lua b/lua/plugins.lua index 2ea31a4..65444d4 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -40,9 +40,5 @@ return require('packer').startup(function() use {'ahmedkhalf/project.nvim'} use {'p00f/nvim-ts-rainbow'} use {'simrat39/symbols-outline.nvim'} - use { - 'akinsho/bufferline.nvim', - requires = 'kyazdani42/nvim-web-devicons' - } use {'f-person/git-blame.nvim'} end) From f77bf366a1836c2f18588004901a19d54858406f Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 09:52:05 +0200 Subject: [PATCH 046/114] Make new tab default behaviour in telescope --- init.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/init.lua b/init.lua index c14f693..d42d29f 100644 --- a/init.lua +++ b/init.lua @@ -79,6 +79,34 @@ 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 lsp_document_diagnostics') +local actions = require('telescope.actions') +require('telescope').setup{ + defaults = { + mappings = { + i = { + [""] = actions.select_tab, + [""] = actions.select_default, + } + }, + }, + pickers = { + -- Your special builtin config goes in here + buffers = { + sort_lastused = true, + previewer = false, + theme = "dropdown", + mappings = { + i = { + [""] = actions.delete_buffer, + [""] = actions.select_default, + }, + n = { + [""] = actions.delete_buffer, + } + } + } + } +} -------------------- LSP ----------------------------------- require('mylsp') From 9de7f54dadeb7610a47929c0b229ec3872fc7de1 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 09:52:27 +0200 Subject: [PATCH 047/114] Refactor some keymappings --- lua/keymappings.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index ac2a8da..12f532b 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -13,21 +13,23 @@ utils.map('n', 'y', '"+y') utils.map('n', 'yy', '"+yy') -- Tabs -utils.map('n', '', ':tabnew .') -utils.map('i', '', ':tabnew .') -utils.map('n', '', ':BufferLineCycleNext') -utils.map('n', '', ':BufferLineCyclePrev') +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') -utils.map('n', '', ':wincmd j') -utils.map('n', '', ':wincmd h') -utils.map('n', '', ':wincmd l') +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 .') -utils.map('i', '', ':vsplit .') +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 .') -utils.map('i', '', ':split .') +utils.map('n', '', ':split .', { noremap = true, silent = true }) +utils.map('i', '', ':split .', { noremap = true, silent = true }) utils.map('n', '', ':wa') @@ -53,8 +55,8 @@ utils.map('v', '<', '', '>gv') -- Highlight word under cursor -utils.map('n', 'ü', ":let @/='\\<=expand(\"\")\\>':set hls") -utils.map('v', 'ü', "y:let @/='=escape(@\",'/\\')':set hls") +utils.map('n', 'ü', ":let @/='\\<=expand(\"\")\\>':set hls", { noremap = true, silent = true }) +utils.map('v', 'ü', "y:let @/='=escape(@\",'/\\')':set hls", { noremap = true, silent = true }) -- Close Buffer utils.map('n', '', ':bd') From df2c98077c9fbf6326c9b46e193e1cb0734c75b5 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 09:52:46 +0200 Subject: [PATCH 048/114] Don't setup ccls --- lua/mylsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 6d84591..2c812fc 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -2,7 +2,7 @@ local nvim_lsp = require 'lspconfig' local utils = require('utils') -- We use the default settings for ccls and pylsp: the option table can stay empty -nvim_lsp.ccls.setup {} +-- nvim_lsp.ccls.setup {} nvim_lsp.pyright.setup{} nvim_lsp.clangd.setup{} nvim_lsp.cmake.setup{} From 9f804b8d0cdc6a3da4aee01aa2014918a6477351 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 09:53:00 +0200 Subject: [PATCH 049/114] Packer is not optional --- lua/plugins.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 65444d4..c0cf066 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,7 +1,7 @@ return require('packer').startup(function() -- Packer can manage itself as an optional plugin - use {'wbthomason/packer.nvim', opt = true} + use {'wbthomason/packer.nvim'} use {'neovim/nvim-lspconfig'} use {'nvim-treesitter/nvim-treesitter'} use { From fa4c72d08e5b664e55d2aaa7bd47d01fa9c8eed8 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 10:02:10 +0200 Subject: [PATCH 050/114] Some refactoring --- init.lua | 45 +------------------------------------------- lua/keymappings.lua | 18 ++++++++++++++++++ lua/my_telescope.lua | 28 +++++++++++++++++++++++++++ lua/mylsp.lua | 39 ++++++++++++++++++++------------------ 4 files changed, 68 insertions(+), 62 deletions(-) create mode 100644 lua/my_telescope.lua diff --git a/init.lua b/init.lua index d42d29f..ffba7d3 100644 --- a/init.lua +++ b/init.lua @@ -56,10 +56,6 @@ utils.opt('o', 'showmatch', true) -------------------- AUTOCOMMANDS -------------------------- require("autocommands") --------------------- MAPPINGS ------------------------------ --- to navigate the completion menu -utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) -utils.map('i', '', 'pumvisible() ? "\\" : "\\"', {expr = true}) -------------------- TREE-SITTER --------------------------- local ts = require 'nvim-treesitter.configs' ts.setup {ensure_installed = 'maintained', highlight = {enable = true}} @@ -67,46 +63,7 @@ ts.setup {ensure_installed = 'maintained', highlight = {enable = true}} -------------------- FZF ----------------------------------- --utils.map('n', '', ':FZF') -------------------- 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', 'r', 'Telescope lsp_references') -utils.map('n', '', 'Telescope lsp_document_symbols') -utils.map('n', '', 'Telescope lsp_document_symbols') -utils.map('n', 'v', 'Telescope lsp_document_diagnostics') -local actions = require('telescope.actions') -require('telescope').setup{ - defaults = { - mappings = { - i = { - [""] = actions.select_tab, - [""] = actions.select_default, - } - }, - }, - pickers = { - -- Your special builtin config goes in here - buffers = { - sort_lastused = true, - previewer = false, - theme = "dropdown", - mappings = { - i = { - [""] = actions.delete_buffer, - [""] = actions.select_default, - }, - n = { - [""] = actions.delete_buffer, - } - } - } - } -} +require('my_telescope') -------------------- LSP ----------------------------------- require('mylsp') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 12f532b..65718f9 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -60,3 +60,21 @@ utils.map('v', 'ü', "y:let @/='=escape(@\",'/\\')':set hls", { -- 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', 'r', 'Telescope lsp_references') +utils.map('n', '', 'Telescope lsp_document_symbols') +utils.map('n', '', 'Telescope lsp_document_symbols') +utils.map('n', 'v', 'Telescope lsp_document_diagnostics') diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua new file mode 100644 index 0000000..812f9f6 --- /dev/null +++ b/lua/my_telescope.lua @@ -0,0 +1,28 @@ +local actions = require('telescope.actions') +require('telescope').setup{ + defaults = { + mappings = { + i = { + [""] = actions.select_tab, + [""] = actions.select_default, + } + }, + }, + pickers = { + -- Your special builtin config goes in here + buffers = { + sort_lastused = true, + previewer = false, + theme = "dropdown", + mappings = { + i = { + [""] = actions.delete_buffer, + [""] = actions.select_default, + }, + n = { + [""] = actions.delete_buffer, + } + } + } + } +} diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 2c812fc..d9a47c2 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -35,29 +35,32 @@ local on_attach = function(client, bufnr) -- Mappings. local opts = { noremap=true, silent=true } - utils.map('n', ',', 'lua vim.lsp.diagnostic.goto_prev()') - utils.map('n', ';', 'lua vim.lsp.diagnostic.goto_next()') - utils.map('n', 'a', 'Telescope lsp_code_actions') - utils.map('n', 'd', 'lua vim.lsp.buf.definition()') - utils.map('n', 'e', 'lua vim.lsp.buf.declaration()') - utils.map('n', 'h', 'lua vim.lsp.buf.hover()') - utils.map('n', 'c', 'lua vim.lsp.buf.outgoing_calls()') - utils.map('n', 'C', 'lua vim.lsp.buf.incoming_calls()') - utils.map('n', 'm', 'lua vim.lsp.buf.rename()') - -- utils.map('n', 'r', 'lua vim.lsp.buf.references()') - utils.map('n', 's', 'lua vim.lsp.buf.document_symbol()') - utils.map('n', '', 'Telescope lsp_dynamic_workspace_symbols') - utils.map('n', 'D', 'lua vim.lsp.buf.type_definition()') - utils.map('n', '', 'lua vim.lsp.buf.signature_help()') - - utils.map('n', '', ':ClangdSwitchSourceHeader') + 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()<, optsCR>') + 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 lsp_document_diagnostics') + 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()') + 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()') + utils.map('v', 'f', 'lua vim.lsp.buf.range_formatting()', opts) end -- Set autocommands conditional on server_capabilities From 879d60c37c80bdb88e00f8dcf391bc3e95819d46 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 22:42:59 +0200 Subject: [PATCH 051/114] Add root dir to lualine --- init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index ffba7d3..b85d702 100644 --- a/init.lua +++ b/init.lua @@ -90,7 +90,10 @@ utils.map('n', '', ':CMake build:copen') require('neoclip').setup() require('telescope').load_extension('neoclip') -------------------- LUALINE ------------------------------- -require('lualine').setup() +require('lualine').setup { + options = {theme = 'gruvbox'}, + sections = {lualine_c = {'getcwd', 'filename', 'bo:filetype'}} +} -------------------- PROJECT ------------------------------- require("project_nvim").setup { silent_chdir = false, From aebef6589d5fb1211e670b580c57e4225b90a4bd Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 22:50:19 +0200 Subject: [PATCH 052/114] Don't use tab for autocomplete selection --- lua/cmp_plug.lua | 8 ++------ lua/keymappings.lua | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua index 502ab1f..0ff0dbf 100644 --- a/lua/cmp_plug.lua +++ b/lua/cmp_plug.lua @@ -45,9 +45,7 @@ cmp.setup { select = true }), [""] = cmp.mapping(function(fallback) - if vim.fn.pumvisible() == 1 then - vim.api.nvim_feedkeys(t(""), "n", true) - elseif luasnip.expand_or_jumpable() then + if luasnip.expand_or_jumpable() then vim.api.nvim_feedkeys(t("luasnip-expand-or-jump"), "", true) else fallback() @@ -57,9 +55,7 @@ cmp.setup { "s", }), [""] = cmp.mapping(function(fallback) - if vim.fn.pumvisible() == 1 then - vim.api.nvim_feedkeys(t(""), "n", true) - elseif luasnip.jumpable(-1) then + if luasnip.jumpable(-1) then vim.api.nvim_feedkeys(t("luasnip-jump-prev"), "", true) else fallback() diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 65718f9..b86098a 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -55,8 +55,6 @@ 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", { noremap = true, silent = true }) -- Close Buffer utils.map('n', '', ':bd') From 3a6724e5c35c6272a9febd67a5dcba240a6b4e34 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 22:54:01 +0200 Subject: [PATCH 053/114] Added autopairs --- init.lua | 2 ++ lua/plugins.lua | 1 + 2 files changed, 3 insertions(+) diff --git a/init.lua b/init.lua index b85d702..ea7b0ad 100644 --- a/init.lua +++ b/init.lua @@ -113,3 +113,5 @@ require'nvim-treesitter.configs'.setup { } -------------------- LUASNIP ------------------------------- require("luasnip.loaders.from_vscode").load() +-------------------- AUTOPAIRS ----------------------------- +require('nvim-autopairs').setup{} diff --git a/lua/plugins.lua b/lua/plugins.lua index c0cf066..6fba26c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -41,4 +41,5 @@ return require('packer').startup(function() use {'p00f/nvim-ts-rainbow'} use {'simrat39/symbols-outline.nvim'} use {'f-person/git-blame.nvim'} + use {'windwp/nvim-autopairs'} end) From a299950ac9d3697c453eb810b2736246cd9f2f30 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 16 Sep 2021 23:15:39 +0200 Subject: [PATCH 054/114] Added shade and some fixes --- init.lua | 14 ++++++++++++++ lua/mylsp.lua | 2 +- lua/plugins.lua | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index ea7b0ad..3c10cb7 100644 --- a/init.lua +++ b/init.lua @@ -115,3 +115,17 @@ require'nvim-treesitter.configs'.setup { require("luasnip.loaders.from_vscode").load() -------------------- AUTOPAIRS ----------------------------- require('nvim-autopairs').setup{} +require("nvim-autopairs.completion.cmp").setup({ + map_cr = true, -- map on insert mode + map_complete = true, -- it will auto insert `(` (map_char) after select function or method item + auto_select = true, -- automatically select the first item + insert = false, -- use insert confirm behavior instead of replace + map_char = { -- modifies the function or method delimiter by filetypes + all = '(', + tex = '{' + } +}) +-------------------- SHADE --------------------------------- +require('shade').setup({ + overlay_opacity = 65 +}) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index d9a47c2..6cd40ef 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -41,7 +41,7 @@ local on_attach = function(client, bufnr) 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()<, optsCR>') + 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()') diff --git a/lua/plugins.lua b/lua/plugins.lua index 6fba26c..210a3ac 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -42,4 +42,5 @@ return require('packer').startup(function() use {'simrat39/symbols-outline.nvim'} use {'f-person/git-blame.nvim'} use {'windwp/nvim-autopairs'} + use {'sunjon/shade.nvim'} end) From 0be1b59cac0e5219950e01444ba0b2dab50364d5 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 17 Sep 2021 08:52:16 +0200 Subject: [PATCH 055/114] Remove shade plugin --- init.lua | 4 ---- lua/plugins.lua | 1 - 2 files changed, 5 deletions(-) diff --git a/init.lua b/init.lua index 3c10cb7..01fb135 100644 --- a/init.lua +++ b/init.lua @@ -125,7 +125,3 @@ require("nvim-autopairs.completion.cmp").setup({ tex = '{' } }) --------------------- SHADE --------------------------------- -require('shade').setup({ - overlay_opacity = 65 -}) diff --git a/lua/plugins.lua b/lua/plugins.lua index 210a3ac..6fba26c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -42,5 +42,4 @@ return require('packer').startup(function() use {'simrat39/symbols-outline.nvim'} use {'f-person/git-blame.nvim'} use {'windwp/nvim-autopairs'} - use {'sunjon/shade.nvim'} end) From 39bf1eddce096f4baeb742e66087a5ec89e0a82c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 17 Sep 2021 09:06:36 +0200 Subject: [PATCH 056/114] =?UTF-8?q?Accidentally=20removed=20the=20=C3=BC?= =?UTF-8?q?=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/keymappings.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index b86098a..741cd92 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -55,6 +55,8 @@ 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') From 19396839191067f74ba3e20115cf55932eec4e03 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 17 Sep 2021 09:30:25 +0200 Subject: [PATCH 057/114] Use tab only for some specific telescope builtins --- lua/my_telescope.lua | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua index 812f9f6..174bd5b 100644 --- a/lua/my_telescope.lua +++ b/lua/my_telescope.lua @@ -1,13 +1,15 @@ local actions = require('telescope.actions') + +local mappingTab = { + i = { + [""] = actions.select_tab, + [""] = actions.select_default, + } +} + +local mappingDefault + require('telescope').setup{ - defaults = { - mappings = { - i = { - [""] = actions.select_tab, - [""] = actions.select_default, - } - }, - }, pickers = { -- Your special builtin config goes in here buffers = { @@ -23,6 +25,15 @@ require('telescope').setup{ [""] = actions.delete_buffer, } } - } + }, + find_files = { + mappings = mappingTab + }, + git_files = { + mappings = mappingTab + }, + lsp_dynamic_workspace_symbols = { + mappings = mappingTab + }, } } From 9d114543c4e33cfdf990a5c5781855d46fd794cb Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 17 Sep 2021 17:30:21 +0200 Subject: [PATCH 058/114] Center after telescope --- lua/my_telescope.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua index 174bd5b..9abec31 100644 --- a/lua/my_telescope.lua +++ b/lua/my_telescope.lua @@ -2,27 +2,33 @@ local actions = require('telescope.actions') local mappingTab = { i = { - [""] = actions.select_tab, - [""] = actions.select_default, + [''] = actions.select_tab, + [''] = actions.select_default, } } -local mappingDefault - -require('telescope').setup{ +require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = actions.close, + [''] = actions.select_default + actions.center + } + } + }, pickers = { -- Your special builtin config goes in here buffers = { sort_lastused = true, previewer = false, - theme = "dropdown", + theme = 'dropdown', mappings = { i = { - [""] = actions.delete_buffer, - [""] = actions.select_default, + [''] = actions.delete_buffer, + [''] = actions.select_default, }, n = { - [""] = actions.delete_buffer, + [''] = actions.delete_buffer, } } }, From a52fa0200bf3585eb1b2255320a5b3cd56712bb1 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 21 Sep 2021 09:25:14 +0200 Subject: [PATCH 059/114] Setup fzf native --- init.lua | 2 ++ lua/plugins.lua | 1 + 2 files changed, 3 insertions(+) diff --git a/init.lua b/init.lua index 01fb135..96792c1 100644 --- a/init.lua +++ b/init.lua @@ -125,3 +125,5 @@ require("nvim-autopairs.completion.cmp").setup({ tex = '{' } }) +-------------------- FZF NATIVE ---------------------------- +require('telescope').load_extension('fzf') diff --git a/lua/plugins.lua b/lua/plugins.lua index 6fba26c..a5be9b3 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -42,4 +42,5 @@ return require('packer').startup(function() use {'simrat39/symbols-outline.nvim'} use {'f-person/git-blame.nvim'} use {'windwp/nvim-autopairs'} + use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'} end) From 1d2e6c77298798f22a157e46dcfaa38917dfc835 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 21 Sep 2021 09:25:33 +0200 Subject: [PATCH 060/114] Quickfix keys --- lua/keymappings.lua | 2 ++ lua/my_telescope.lua | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 741cd92..e5686ba 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -74,6 +74,8 @@ 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 loclist') utils.map('n', 'r', 'Telescope lsp_references') utils.map('n', '', 'Telescope lsp_document_symbols') utils.map('n', '', 'Telescope lsp_document_symbols') diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua index 9abec31..6fc021e 100644 --- a/lua/my_telescope.lua +++ b/lua/my_telescope.lua @@ -12,7 +12,9 @@ require('telescope').setup { mappings = { i = { [''] = actions.close, - [''] = actions.select_default + actions.center + [''] = actions.select_default + actions.center, + [''] = actions.send_selected_to_loclist, + [''] = actions.smart_send_to_qflist } } }, From bc1e4bb74225f70cc050a058ba384c832860a6a7 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 21 Sep 2021 09:25:45 +0200 Subject: [PATCH 061/114] lsp-status added --- init.lua | 3 ++- lua/mylsp.lua | 11 ++++++++++- lua/plugins.lua | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 96792c1..e0df2d4 100644 --- a/init.lua +++ b/init.lua @@ -92,7 +92,8 @@ require('telescope').load_extension('neoclip') -------------------- LUALINE ------------------------------- require('lualine').setup { options = {theme = 'gruvbox'}, - sections = {lualine_c = {'getcwd', 'filename', 'bo:filetype'}} + sections = {lualine_c = {'getcwd', 'filename', 'bo:filetype'}, + lualine_z = {"require('lsp-status').update_current_function()", "require('lsp-status').status()"}} } -------------------- PROJECT ------------------------------- require("project_nvim").setup { diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 6cd40ef..eae6c47 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -1,10 +1,19 @@ local nvim_lsp = require 'lspconfig' local utils = require('utils') +local lsp_status = require('lsp-status') +lsp_status.register_progress() -- We use the default settings for ccls and pylsp: the option table can stay empty -- nvim_lsp.ccls.setup {} nvim_lsp.pyright.setup{} -nvim_lsp.clangd.setup{} +nvim_lsp.clangd.setup{ + handlers = lsp_status.extensions.clangd.setup(), + init_options = { + clangdFileStatus = true + }, + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +} nvim_lsp.cmake.setup{} nvim_lsp.jsonls.setup{} diff --git a/lua/plugins.lua b/lua/plugins.lua index a5be9b3..10778ab 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -43,4 +43,5 @@ return require('packer').startup(function() use {'f-person/git-blame.nvim'} use {'windwp/nvim-autopairs'} use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'} + use {'nvim-lua/lsp-status.nvim'} end) From a3fbe547ad1907abe5b60b062a2d102df70011ee Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 21 Sep 2021 11:44:50 +0200 Subject: [PATCH 062/114] Setup the groovy language server --- lua/mylsp.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index eae6c47..39b7ca4 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -16,6 +16,10 @@ nvim_lsp.clangd.setup{ } nvim_lsp.cmake.setup{} nvim_lsp.jsonls.setup{} +nvim_lsp.groovyls.setup{ + -- Unix + cmd = { "java", "-jar", "D:/tmp/groovy-language-server/build/libs/groovy-language-server-all.jar" } +} -- Add additional capabilities supported by nvim-cmp From 9b1238f318a3c904eca64208db953cefef8a89b7 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 21 Sep 2021 11:45:08 +0200 Subject: [PATCH 063/114] Revert "lsp-status added" This reverts commit bc1e4bb74225f70cc050a058ba384c832860a6a7. --- init.lua | 3 +-- lua/mylsp.lua | 11 +---------- lua/plugins.lua | 1 - 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/init.lua b/init.lua index e0df2d4..96792c1 100644 --- a/init.lua +++ b/init.lua @@ -92,8 +92,7 @@ require('telescope').load_extension('neoclip') -------------------- LUALINE ------------------------------- require('lualine').setup { options = {theme = 'gruvbox'}, - sections = {lualine_c = {'getcwd', 'filename', 'bo:filetype'}, - lualine_z = {"require('lsp-status').update_current_function()", "require('lsp-status').status()"}} + sections = {lualine_c = {'getcwd', 'filename', 'bo:filetype'}} } -------------------- PROJECT ------------------------------- require("project_nvim").setup { diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 39b7ca4..9598406 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -1,19 +1,10 @@ local nvim_lsp = require 'lspconfig' local utils = require('utils') -local lsp_status = require('lsp-status') -lsp_status.register_progress() -- We use the default settings for ccls and pylsp: the option table can stay empty -- nvim_lsp.ccls.setup {} nvim_lsp.pyright.setup{} -nvim_lsp.clangd.setup{ - handlers = lsp_status.extensions.clangd.setup(), - init_options = { - clangdFileStatus = true - }, - on_attach = lsp_status.on_attach, - capabilities = lsp_status.capabilities -} +nvim_lsp.clangd.setup{} nvim_lsp.cmake.setup{} nvim_lsp.jsonls.setup{} nvim_lsp.groovyls.setup{ diff --git a/lua/plugins.lua b/lua/plugins.lua index 10778ab..a5be9b3 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -43,5 +43,4 @@ return require('packer').startup(function() use {'f-person/git-blame.nvim'} use {'windwp/nvim-autopairs'} use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'} - use {'nvim-lua/lsp-status.nvim'} end) From 0bcb681f7b60c066f2bf2c38c7fe3bc224fa205a Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 23 Sep 2021 09:15:50 +0200 Subject: [PATCH 064/114] Disable relative line number --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 96792c1..e408f15 100644 --- a/init.lua +++ b/init.lua @@ -36,7 +36,7 @@ utils.opt('o', 'hidden', true) utils.opt('o', 'ignorecase', true) utils.opt('o', 'scrolloff', 4 ) utils.opt('o', 'shiftround', true) -utils.opt('o', 'relativenumber', true) +utils.opt('o', 'relativenumber', false) utils.opt('o', 'smartcase', true) utils.opt('o', 'splitbelow', true) utils.opt('o', 'splitright', true) From b8542885c88c8648dd20fdfac07a70043af2e4f2 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 23 Sep 2021 12:56:51 +0200 Subject: [PATCH 065/114] added function name to lualine --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index e408f15..003f406 100644 --- a/init.lua +++ b/init.lua @@ -92,7 +92,8 @@ require('telescope').load_extension('neoclip') -------------------- LUALINE ------------------------------- require('lualine').setup { options = {theme = 'gruvbox'}, - sections = {lualine_c = {'getcwd', 'filename', 'bo:filetype'}} + sections = {lualine_c = {'getcwd', 'filename', 'nvim_treesitter#statusline'}, + } } -------------------- PROJECT ------------------------------- require("project_nvim").setup { From 367d71db4b2e24be004c8cbbfda73cf184ad3674 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 23 Sep 2021 13:06:44 +0200 Subject: [PATCH 066/114] Use tabs with oldfiles --- lua/my_telescope.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua index 6fc021e..f9b3110 100644 --- a/lua/my_telescope.lua +++ b/lua/my_telescope.lua @@ -37,6 +37,9 @@ require('telescope').setup { find_files = { mappings = mappingTab }, + oldfiles = { + mappings = mappingTab + }, git_files = { mappings = mappingTab }, From 8af863e0cd5da47ddf1771e42962c400a9f09985 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 23 Sep 2021 23:03:29 +0200 Subject: [PATCH 067/114] Set keymap for live grep and neoclip --- lua/keymappings.lua | 3 ++- lua/plugins.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index e5686ba..9ccf829 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -75,8 +75,9 @@ 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 loclist') +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 lsp_document_diagnostics') +utils.map('n', '', 'Telescope neoclip plus') diff --git a/lua/plugins.lua b/lua/plugins.lua index a5be9b3..32b9f0b 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -6,7 +6,7 @@ return require('packer').startup(function() use {'nvim-treesitter/nvim-treesitter'} use { 'nvim-telescope/telescope.nvim', - requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} + requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}, {'kyazdani42/nvim-web-devicons'}} } use {'sainnhe/gruvbox-material'} use {'lukas-reineke/indent-blankline.nvim'} From 19c5b0dd9618e04673ad046335861af4fdaf7112 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 23 Sep 2021 23:04:23 +0200 Subject: [PATCH 068/114] Use utf-8 lang --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 003f406..327e4ae 100644 --- a/init.lua +++ b/init.lua @@ -21,7 +21,7 @@ require('keymappings') cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme here cmd 'syntax enable' cmd 'filetype plugin indent on' -cmd 'language en_US' +cmd 'language en_US.utf-8' utils.opt('o', 'hlsearch', true) utils.opt('o', 'guifont', 'Hack NF:h9') utils.opt('o', 'swapfile', false) From 308e904be3982f6b0a97d13465c39b0afbe9baf3 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 23 Sep 2021 23:09:22 +0200 Subject: [PATCH 069/114] Neoclip set default register to plus --- init.lua | 4 +++- lua/keymappings.lua | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 327e4ae..4ecc320 100644 --- a/init.lua +++ b/init.lua @@ -87,7 +87,9 @@ require('telescope').load_extension('cmake') g.cmake_build_dir = '{cwd}/build_nvim' utils.map('n', '', ':CMake build:copen') -------------------- NEOCLIP ------------------------------- -require('neoclip').setup() +require('neoclip').setup({ + default_register = '+', +}) require('telescope').load_extension('neoclip') -------------------- LUALINE ------------------------------- require('lualine').setup { diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 9ccf829..61615fd 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -80,4 +80,4 @@ 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 lsp_document_diagnostics') -utils.map('n', '', 'Telescope neoclip plus') +utils.map('n', '', 'Telescope neoclip') From 2c87a198642f8b39c3c2c0be04393c8b402fa43a Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 24 Sep 2021 08:22:46 +0200 Subject: [PATCH 070/114] Enable gitsigns --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 4ecc320..4ef7532 100644 --- a/init.lua +++ b/init.lua @@ -68,7 +68,7 @@ require('my_telescope') require('mylsp') -------------------- GITSIGNS ------------------------------ --- require('gitsigns').setup() +require('gitsigns').setup() -------------------- LIGHTBULB ----------------------------- require('nvim-lightbulb').update_lightbulb() vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()]] From f196a645eb19c31c525301b96edc0bf17d59f5e1 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Mon, 27 Sep 2021 08:23:38 +0200 Subject: [PATCH 071/114] Removed the duplicated relativenumber option --- init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/init.lua b/init.lua index 4ef7532..eec0b31 100644 --- a/init.lua +++ b/init.lua @@ -42,7 +42,6 @@ utils.opt('o', 'splitbelow', true) utils.opt('o', 'splitright', true) utils.opt('o', 'wildmode', 'list:longest') utils.opt('w', 'number', true) -utils.opt('w', 'relativenumber', true) utils.opt('o', 'clipboard', 'unnamed,unnamedplus') utils.opt('o', 'mouse', 'a') utils.opt('o', 'wrap', false) From 4baeac32e6ae39913a7f02ad76bc96f07a07cd5a Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Mon, 27 Sep 2021 10:18:17 +0200 Subject: [PATCH 072/114] Start with esc when range formatting --- lua/mylsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 9598406..877e281 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -64,7 +64,7 @@ local on_attach = function(client, bufnr) 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) + utils.map('v', 'f', 'lua vim.lsp.buf.range_formatting()', opts) end -- Set autocommands conditional on server_capabilities From 3c5737487210caaafa1b9edf0ca556925187191e Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 12 Oct 2021 22:22:02 +0200 Subject: [PATCH 073/114] Replace comment plugin --- init.lua | 13 ++++++++++++- lua/plugins.lua | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index eec0b31..a27c0c6 100644 --- a/init.lua +++ b/init.lua @@ -80,7 +80,18 @@ utils.map('n', 'tt', 'NvimTreeToggle') g.nvim_tree_follow = 1 g.nvim_tree_highlight_opened_files = 1 -------------------- COMMENTED ----------------------------- -require('commented').setup() +require('Comment').setup({ + toggler = { + ---line-comment toggle + line = 'cc', + block = 'bc', + }, + opleader = { + ---line-comment opfunc mapping + line = 'c', + block = 'b', + }, +}) -------------------- CMAKE --------------------------------- require('telescope').load_extension('cmake') g.cmake_build_dir = '{cwd}/build_nvim' diff --git a/lua/plugins.lua b/lua/plugins.lua index 32b9f0b..4cb2e48 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -17,7 +17,7 @@ return require('packer').startup(function() 'kyazdani42/nvim-tree.lua', requires = 'kyazdani42/nvim-web-devicons' } - use{'winston0410/commented.nvim'} + use{'numToStr/Comment.nvim'} use { 'hrsh7th/nvim-cmp', requires = { From fb7df21f6861bd6696659777ab362c7eb9a637d0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 12 Oct 2021 22:47:58 +0200 Subject: [PATCH 074/114] Fixed nvim-tree config --- init.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index a27c0c6..ba28463 100644 --- a/init.lua +++ b/init.lua @@ -74,10 +74,17 @@ vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_li -------------------- CMP ----------------------------------- require('cmp_plug') -------------------- NVIM-TREE ----------------------------- -g.nvim_tree_auto_open = 0 --- g.nvim_tree_show_icons = { 'git': 1, 'folders': 1, 'files': 1, 'folder_arrows': 1 } +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, + }, +}) utils.map('n', 'tt', 'NvimTreeToggle') -g.nvim_tree_follow = 1 g.nvim_tree_highlight_opened_files = 1 -------------------- COMMENTED ----------------------------- require('Comment').setup({ @@ -112,7 +119,6 @@ require("project_nvim").setup { silent_chdir = false, } require('telescope').load_extension('projects') -g.nvim_tree_update_cwd = 1 utils.map('n', 'p', 'Telescope projects') -------------------- TS-RAINBOW ---------------------------- require'nvim-treesitter.configs'.setup { From e3797038a25f3b4ca949ff4806da8e1f1fff682b Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 12 Oct 2021 22:48:08 +0200 Subject: [PATCH 075/114] silent project change --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index ba28463..021699b 100644 --- a/init.lua +++ b/init.lua @@ -116,7 +116,7 @@ require('lualine').setup { } -------------------- PROJECT ------------------------------- require("project_nvim").setup { - silent_chdir = false, + silent_chdir = true, } require('telescope').load_extension('projects') utils.map('n', 'p', 'Telescope projects') From 548c62f55984c1f98f9b3c9afd6bf117c0669329 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 12 Oct 2021 22:48:26 +0200 Subject: [PATCH 076/114] Removed duplicate keymapping --- init.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/init.lua b/init.lua index 021699b..cbc7223 100644 --- a/init.lua +++ b/init.lua @@ -91,12 +91,10 @@ require('Comment').setup({ toggler = { ---line-comment toggle line = 'cc', - block = 'bc', }, opleader = { ---line-comment opfunc mapping line = 'c', - block = 'b', }, }) -------------------- CMAKE --------------------------------- From 92d1850855eee7888a2d2154ca14fbb2cf79a84b Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 12 Oct 2021 23:27:07 +0200 Subject: [PATCH 077/114] Removed unused files --- LUL9KAMW.vim | 5 ----- UUL4JKMG.vim | 5 ----- coc-settings.json | 13 ------------- coc-settings_win.json | 9 --------- ginit.vim | 21 --------------------- perryLinux64.vim | 4 ---- perryWin64.vim | 5 ----- 7 files changed, 62 deletions(-) delete mode 100644 LUL9KAMW.vim delete mode 100644 UUL4JKMG.vim delete mode 100644 coc-settings.json delete mode 100644 coc-settings_win.json delete mode 100644 ginit.vim delete mode 100644 perryLinux64.vim delete mode 100644 perryWin64.vim 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/ginit.vim b/ginit.vim deleted file mode 100644 index c001d34..0000000 --- a/ginit.vim +++ /dev/null @@ -1,21 +0,0 @@ -" set mouse=a -if has("win32") - Guifont! Hack NF:h9 -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/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' From 2bbe00713bed1deca2f3e95fa7f1ac41dda4ccc6 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 12 Oct 2021 23:30:39 +0200 Subject: [PATCH 078/114] delete the ansiesc autocommand --- lua/autocommands.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index ef21744..50f7ee5 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -26,9 +26,6 @@ local autocmds = { lua_highlight = { { 'TextYankPost', '*', [[silent! lua vim.highlight.on_yank() {higroup='IncSearch', timeout=400}]] }; }; - ansi_esc_log = { - { 'BufEnter', '*.log', ':AnsiEsc' }; - }; file_type = { {'BufRead,BufNewFile', '*.simvis', 'set filetype=xml'}; {'BufRead,BufNewFile', '*.simcfg,*.simcon,*.simudex', 'set filetype=cfg'}; From ad10e32e099d2f8bd3de72884e7c716e03fc4b4d Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 12 Oct 2021 23:38:04 +0200 Subject: [PATCH 079/114] More nvim-tree config --- init.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index cbc7223..76642ef 100644 --- a/init.lua +++ b/init.lua @@ -77,15 +77,25 @@ require('cmp_plug') require('nvim-tree').setup({ auto_close = true, update_cwd = true, - update_to_buf_dir = { - -- enable the feature + -- update_to_buf_dir = { + -- -- enable the feature + -- enable = true, + -- -- allow to open the tree if it was previously closed + -- auto_open = false, + -- }, + diagnostics = { enable = true, - -- allow to open the tree if it was previously closed - auto_open = false, + 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 = { From 505a55df18aabbd0ac7dc034e3ee50269b861a00 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 12 Oct 2021 23:44:57 +0200 Subject: [PATCH 080/114] Added signs for lsp info/warning/error --- lua/mylsp.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 877e281..6ee0d34 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -91,3 +91,9 @@ for _, lsp in ipairs(servers) do capabilities = capabilities, } end + +local signs = { Error = " ", Warning = " ", Hint = " ", Information = " " } +for type, icon in pairs(signs) do + local hl = "LspDiagnosticsSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end From 4086148b38218aafab71c8db5a737a92c2135150 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 13 Oct 2021 08:05:33 +0200 Subject: [PATCH 081/114] Check file time after entering a buf --- lua/autocommands.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 50f7ee5..0386138 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -32,6 +32,9 @@ local autocmds = { {'BufRead,BufNewFile', 'Jenkinsfile*', 'set filetype=groovy'}; {'BufRead,BufNewFile', '*.manifest', 'set filetype=xml'}; {'BufRead,BufNewFile', 'SConstruct,SConscript', 'set filetype=python'}; + }; + file_changed = { + {'BufEnter,FocusGained', '*', 'checktime'}; } } From b2638165ff200e422782c1ba961fbf0c3e522882 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 13 Oct 2021 14:08:42 +0200 Subject: [PATCH 082/114] Fixed writing of shada files --- lua/autocommands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 0386138..983ab72 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -18,7 +18,7 @@ local autocmds = { { 'BufRead', '*', [[call setpos(".", getpos("'\""))]] }; }; save_shada = { - {'VimLeave', '*', 'wshada!'}; + {'CursorHold,FocusGained,FocusLost', '*', 'rshada|wshada'}; }; resize_windows_proportionally = { { 'VimResized', '*', ':wincmd =' }; From 8818bd0a7a093459b330244ca7cfe42b89071e51 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 13 Oct 2021 23:57:50 +0200 Subject: [PATCH 083/114] Refactor treesitter config --- init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 76642ef..22f49fd 100644 --- a/init.lua +++ b/init.lua @@ -56,8 +56,12 @@ utils.opt('o', 'showmatch', true) -------------------- AUTOCOMMANDS -------------------------- require("autocommands") -------------------- TREE-SITTER --------------------------- -local ts = require 'nvim-treesitter.configs' -ts.setup {ensure_installed = 'maintained', highlight = {enable = true}} +require('nvim-treesitter.configs').setup({ + ensure_installed = 'maintained', + highlight = { + enable = true + } +}) -------------------- FZF ----------------------------------- --utils.map('n', '', ':FZF') From 34468c3cdfc6e8497fcc7332e58f5b79078510d9 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 13 Oct 2021 23:58:07 +0200 Subject: [PATCH 084/114] No auto comment in newline --- lua/autocommands.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 983ab72..4a169c8 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -35,6 +35,9 @@ local autocmds = { }; file_changed = { {'BufEnter,FocusGained', '*', 'checktime'}; + }; + no_auto_comment = { + {'BufEnter', '*', 'set fo-=c fo-=r fo-=o'} } } From 936a24e8583bef8670f778a8abdd529a889f1fb8 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 13 Oct 2021 23:58:41 +0200 Subject: [PATCH 085/114] vertical wildmenu --- init.lua | 2 +- lua/keymappings.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 22f49fd..51bcc60 100644 --- a/init.lua +++ b/init.lua @@ -40,7 +40,7 @@ utils.opt('o', 'relativenumber', false) utils.opt('o', 'smartcase', true) utils.opt('o', 'splitbelow', true) utils.opt('o', 'splitright', true) -utils.opt('o', 'wildmode', 'list:longest') +utils.opt('o', 'wildmode', 'longest:full,full') utils.opt('w', 'number', true) utils.opt('o', 'clipboard', 'unnamed,unnamedplus') utils.opt('o', 'mouse', 'a') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 61615fd..f66f655 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -81,3 +81,6 @@ utils.map('n', '', 'Telescope lsp_document_symbols') utils.map('n', '', 'Telescope lsp_document_symbols') utils.map('n', 'v', 'Telescope lsp_document_diagnostics') utils.map('n', '', 'Telescope neoclip') +-- wildmode +utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) +utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) From 957d91f7426f10535373aae30115b51945c66bf1 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Wed, 13 Oct 2021 23:58:52 +0200 Subject: [PATCH 086/114] Removed fzf config --- init.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/init.lua b/init.lua index 51bcc60..545c63f 100644 --- a/init.lua +++ b/init.lua @@ -63,8 +63,6 @@ require('nvim-treesitter.configs').setup({ } }) --------------------- FZF ----------------------------------- ---utils.map('n', '', ':FZF') -------------------- TELESCOPE ----------------------------- require('my_telescope') -------------------- LSP ----------------------------------- From 04de46c39a5e0c7ac3bf52fb1309e555d355dbb6 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 14 Oct 2021 00:09:09 +0200 Subject: [PATCH 087/114] More keymappings for wildmenu --- lua/keymappings.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index f66f655..e5d157f 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -84,3 +84,6 @@ utils.map('n', '', 'Telescope neoclip') -- wildmode utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) +utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) +utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) +utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) From cccb9812c7a7b5357711594e19661921745f8933 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 14 Oct 2021 00:09:31 +0200 Subject: [PATCH 088/114] Format --- lua/keymappings.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index e5d157f..dd5d966 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -81,6 +81,7 @@ utils.map('n', '', 'Telescope lsp_document_symbols') utils.map('n', '', 'Telescope lsp_document_symbols') utils.map('n', 'v', 'Telescope lsp_document_diagnostics') utils.map('n', '', 'Telescope neoclip') + -- wildmode utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) From 789fe2faa95fcd2f88d647eaaaa68a877789c169 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 14 Oct 2021 14:52:35 +0200 Subject: [PATCH 089/114] Added keymapping for symbols outline --- lua/keymappings.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index dd5d966..44d9b70 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -88,3 +88,7 @@ utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = tr utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) + +-- Symbols Outline +utils.map('n', 'ss', 'SymbolsOutline') + From 97cf6a51f45efdf529ac715878aacfafb7bd0a78 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 14 Oct 2021 14:52:50 +0200 Subject: [PATCH 090/114] Added signature plugin --- lua/mylsp.lua | 7 +++++++ lua/plugins.lua | 1 + 2 files changed, 8 insertions(+) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 6ee0d34..2864116 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -81,6 +81,13 @@ local on_attach = function(client, bufnr) 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 -- Enable some language servers with the additional completion capabilities offered by nvim-cmp diff --git a/lua/plugins.lua b/lua/plugins.lua index 4cb2e48..f2caf7f 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -43,4 +43,5 @@ return require('packer').startup(function() 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'} end) From 124e39c4b7be2d512044fd557875dd7be81cc70d Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Thu, 14 Oct 2021 20:06:34 +0200 Subject: [PATCH 091/114] Fixed symbols outline --- lua/keymappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 44d9b70..f7c2385 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -90,5 +90,5 @@ utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {exp utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) -- Symbols Outline -utils.map('n', 'ss', 'SymbolsOutline') +utils.map('n', 's', 'SymbolsOutline') From 70fc061d1accb7e773b2835a10ba1c3e7cd8a16c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 6 Nov 2021 13:01:21 +0100 Subject: [PATCH 092/114] CMake config --- init.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 545c63f..aad52b4 100644 --- a/init.lua +++ b/init.lua @@ -111,8 +111,18 @@ require('Comment').setup({ }) -------------------- CMAKE --------------------------------- require('telescope').load_extension('cmake') -g.cmake_build_dir = '{cwd}/build_nvim' +local Path = require('plenary.path') +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 = '+', From 64c4e0cf2979a940648665fe3766fd39df15b8c1 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 6 Nov 2021 13:01:54 +0100 Subject: [PATCH 093/114] INDENT-BLANKLINE --- init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/init.lua b/init.lua index aad52b4..a14bd73 100644 --- a/init.lua +++ b/init.lua @@ -166,3 +166,15 @@ require("nvim-autopairs.completion.cmp").setup({ }) -------------------- FZF NATIVE ---------------------------- require('telescope').load_extension('fzf') +-------------------- 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'}, +} From d92d380f7a83c60d569eded9b3d47584248a9cee Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 6 Nov 2021 13:02:24 +0100 Subject: [PATCH 094/114] Terminal --- init.lua | 4 ++++ lua/plugins.lua | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/init.lua b/init.lua index a14bd73..6190213 100644 --- a/init.lua +++ b/init.lua @@ -166,6 +166,10 @@ require("nvim-autopairs.completion.cmp").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: ") diff --git a/lua/plugins.lua b/lua/plugins.lua index f2caf7f..54936fe 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -44,4 +44,9 @@ return require('packer').startup(function() 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'} +} end) From d74a4b757600a2fc7119c9a22deb58549e6f7f8d Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 6 Nov 2021 13:03:29 +0100 Subject: [PATCH 095/114] Enable lsp install plugin --- init.lua | 2 +- lua/my_lspinstall.lua | 94 +++++++++++++++++++++++++++++++++++++++++++ lua/mylsp.lua | 29 ++++++++++++- 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 lua/my_lspinstall.lua diff --git a/init.lua b/init.lua index 6190213..5fd8281 100644 --- a/init.lua +++ b/init.lua @@ -66,8 +66,8 @@ require('nvim-treesitter.configs').setup({ -------------------- TELESCOPE ----------------------------- require('my_telescope') -------------------- LSP ----------------------------------- -require('mylsp') +require('my_lspinstall') -------------------- GITSIGNS ------------------------------ require('gitsigns').setup() -------------------- LIGHTBULB ----------------------------- diff --git a/lua/my_lspinstall.lua b/lua/my_lspinstall.lua new file mode 100644 index 0000000..75f59b6 --- /dev/null +++ b/lua/my_lspinstall.lua @@ -0,0 +1,94 @@ +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 lsp_document_diagnostics') + 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) diff --git a/lua/mylsp.lua b/lua/mylsp.lua index 2864116..e2c3992 100644 --- a/lua/mylsp.lua +++ b/lua/mylsp.lua @@ -1,6 +1,19 @@ local nvim_lsp = require 'lspconfig' local utils = require('utils') +local system_name +if vim.fn.has("mac") == 1 then + system_name = "macOS" +elseif vim.fn.has("unix") == 1 then + system_name = "Linux" +elseif vim.fn.has('win32') == 1 then + system_name = "Windows" +else + print("Unsupported system for sumneko") +end + +local sumneko_root_path = 'D:/tmp/lua-language-server' +local sumneko_binary = sumneko_root_path.."/bin/"..system_name.."/lua-language-server" -- We use the default settings for ccls and pylsp: the option table can stay empty -- nvim_lsp.ccls.setup {} nvim_lsp.pyright.setup{} @@ -12,7 +25,6 @@ nvim_lsp.groovyls.setup{ cmd = { "java", "-jar", "D:/tmp/groovy-language-server/build/libs/groovy-language-server-all.jar" } } - -- Add additional capabilities supported by nvim-cmp local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.documentationFormat = { 'markdown', 'plaintext' } @@ -91,7 +103,7 @@ local on_attach = function(client, bufnr) end -- Enable some language servers with the additional completion capabilities offered by nvim-cmp -local servers = { 'clangd', 'pyright', 'cmake', 'jsonls' } +local servers = {'clangd', 'pyright', 'cmake', 'jsonls'} for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach, @@ -99,6 +111,19 @@ for _, lsp in ipairs(servers) do } end +nvim_lsp.sumneko_lua.setup{ + cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, + on_attach = on_attach, + capabilities = capabilities, +} + +nvim_lsp.groovyls.setup{ + -- Unix + cmd = { "java", "-jar", "D:/tmp/groovy-language-server/build/libs/groovy-language-server-all.jar" }, + on_attach = on_attach, + capabilities = capabilities, +} + local signs = { Error = " ", Warning = " ", Hint = " ", Information = " " } for type, icon in pairs(signs) do local hl = "LspDiagnosticsSign" .. type From 63fa8c9579fe178fefac270df54f9a5247f882e4 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 6 Nov 2021 13:03:49 +0100 Subject: [PATCH 096/114] Change telescope themes --- lua/my_telescope.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua index f9b3110..8e94af4 100644 --- a/lua/my_telescope.lua +++ b/lua/my_telescope.lua @@ -22,8 +22,7 @@ require('telescope').setup { -- Your special builtin config goes in here buffers = { sort_lastused = true, - previewer = false, - theme = 'dropdown', + theme = 'ivy', mappings = { i = { [''] = actions.delete_buffer, @@ -35,13 +34,16 @@ require('telescope').setup { } }, find_files = { - mappings = mappingTab + mappings = mappingTab, + theme = 'ivy', }, oldfiles = { - mappings = mappingTab + mappings = mappingTab, + theme = 'ivy', }, git_files = { - mappings = mappingTab + mappings = mappingTab, + theme = 'ivy', }, lsp_dynamic_workspace_symbols = { mappings = mappingTab From b7c97e6be07a563bd816978c99c18df28bd77e2c Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 6 Nov 2021 13:04:04 +0100 Subject: [PATCH 097/114] Jumplist hotkey --- lua/keymappings.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index f7c2385..9e3dc32 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -81,6 +81,7 @@ utils.map('n', '', 'Telescope lsp_document_symbols') utils.map('n', '', 'Telescope lsp_document_symbols') utils.map('n', 'v', 'Telescope lsp_document_diagnostics') utils.map('n', '', 'Telescope neoclip') +utils.map('n', 'j', 'Telescope jumplist') -- wildmode utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) From 487e25bbe515b42c41e2c17c16ae8414049f33e2 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 6 Nov 2021 13:04:20 +0100 Subject: [PATCH 098/114] Only write shada when focus changes --- lua/autocommands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 4a169c8..3fb7b3e 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -18,7 +18,7 @@ local autocmds = { { 'BufRead', '*', [[call setpos(".", getpos("'\""))]] }; }; save_shada = { - {'CursorHold,FocusGained,FocusLost', '*', 'rshada|wshada'}; + {'FocusGained,FocusLost', '*', 'rshada|wshada'}; }; resize_windows_proportionally = { { 'VimResized', '*', ':wincmd =' }; From e142a3ec5b3116aa326f803b04b9f09f4e129733 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 9 Nov 2021 09:37:08 +0100 Subject: [PATCH 099/114] nvimtree. open folder from current file --- init.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 5fd8281..3e175e4 100644 --- a/init.lua +++ b/init.lua @@ -79,12 +79,17 @@ require('cmp_plug') 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_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 = { From f4631cbaa250a7d1def9d275c9be41c9d37ef78e Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 19 Nov 2021 17:37:42 +0100 Subject: [PATCH 100/114] Configure nvim-cmp for s and c mode --- lua/cmp_plug.lua | 34 ++++++++++++++++++++++++++-------- lua/keymappings.lua | 5 ----- lua/plugins.lua | 2 +- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua index 0ff0dbf..cff3984 100644 --- a/lua/cmp_plug.lua +++ b/lua/cmp_plug.lua @@ -34,15 +34,16 @@ cmp.setup { end }, mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), + [''] = 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.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true + [''] = 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 @@ -76,9 +77,26 @@ cmp.setup { {name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"}, {name = "emoji"} }, - completion = {completeopt = 'menu,menuone,noinsert'} + 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' } + }), +}) + -- Autopairs --require("nvim-autopairs.completion.cmp").setup({ -- map_cr = true, diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 9e3dc32..13fc70e 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -84,11 +84,6 @@ utils.map('n', '', 'Telescope neoclip') utils.map('n', 'j', 'Telescope jumplist') -- wildmode -utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) -utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) -utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) -utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) -utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) -- Symbols Outline utils.map('n', 's', 'SymbolsOutline') diff --git a/lua/plugins.lua b/lua/plugins.lua index 54936fe..0171e7e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -24,7 +24,7 @@ return require('packer').startup(function() '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' + 'f3fora/cmp-spell', 'hrsh7th/cmp-emoji', 'hrsh7th/cmp-cmdline' } } use {'rafamadriz/friendly-snippets'} From c43f43f6d43c4915f9bff06146839426cfd946cb Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 19 Nov 2021 18:10:05 +0100 Subject: [PATCH 101/114] Also have buffer completion in command mode --- lua/cmp_plug.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua index cff3984..0882f4f 100644 --- a/lua/cmp_plug.lua +++ b/lua/cmp_plug.lua @@ -94,6 +94,8 @@ cmp.setup.cmdline(':', { { name = 'path' } }, { { name = 'cmdline' } + }, { + { name = 'buffer' } }), }) From 9160e3c7adb739d2a69a11a982bfd4fb9d55cd8e Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 19 Nov 2021 13:40:26 +0100 Subject: [PATCH 102/114] Don't use tabs as default --- lua/my_telescope.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua index 8e94af4..23d08e7 100644 --- a/lua/my_telescope.lua +++ b/lua/my_telescope.lua @@ -34,19 +34,15 @@ require('telescope').setup { } }, find_files = { - mappings = mappingTab, theme = 'ivy', }, oldfiles = { - mappings = mappingTab, theme = 'ivy', }, git_files = { - mappings = mappingTab, theme = 'ivy', }, lsp_dynamic_workspace_symbols = { - mappings = mappingTab }, } } From a65d705b29294ec688138190f66c9c4991637dc4 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Fri, 19 Nov 2021 13:41:02 +0100 Subject: [PATCH 103/114] Update cmake plugin --- lua/plugins.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index 0171e7e..93e7aa5 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -30,7 +30,7 @@ return require('packer').startup(function() use {'rafamadriz/friendly-snippets'} use {'onsails/lspkind-nvim'} use {'Shatur/neovim-cmake', - requires = {'mfussenegger/nvim-dap', 'skywind3000/asyncrun.vim'} + requires = {'mfussenegger/nvim-dap'} } use {'AckslD/nvim-neoclip.lua'} use { From a4de713457eb00291dc7bca8b6dee52eec3ab5c9 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 19 Dec 2021 22:51:09 +0100 Subject: [PATCH 104/114] Added null-ls --- init.lua | 10 ++++++++++ lua/plugins.lua | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 3e175e4..9d3ca67 100644 --- a/init.lua +++ b/init.lua @@ -187,3 +187,13 @@ require("indent_blankline").setup { show_current_context = true, context_patterns = {'class', 'function', 'method', 'block', '^if', '^for', '^while'}, } + +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 + } +} diff --git a/lua/plugins.lua b/lua/plugins.lua index 93e7aa5..a09ff4a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -48,5 +48,9 @@ return require('packer').startup(function() use { 'williamboman/nvim-lsp-installer', requires = {'neovim/nvim-lspconfig'} -} + } + use { + 'jose-elias-alvarez/null-ls.nvim', + requires = {'nvim-lua/plenary.nvim'} + } end) From 33d7b260c040429d89fdf452d68613832e513b4b Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 19 Dec 2021 22:51:26 +0100 Subject: [PATCH 105/114] Disable undefined-global for lua lsp --- .luarc.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .luarc.json 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"] +} + From 1394c013a448bb20edcdf1d3824185b6f578c364 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 19 Dec 2021 23:10:38 +0100 Subject: [PATCH 106/114] Fixed autoparis warning --- init.lua | 10 ---------- lua/cmp_plug.lua | 2 ++ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/init.lua b/init.lua index 9d3ca67..d2bb709 100644 --- a/init.lua +++ b/init.lua @@ -159,16 +159,6 @@ require'nvim-treesitter.configs'.setup { require("luasnip.loaders.from_vscode").load() -------------------- AUTOPAIRS ----------------------------- require('nvim-autopairs').setup{} -require("nvim-autopairs.completion.cmp").setup({ - map_cr = true, -- map on insert mode - map_complete = true, -- it will auto insert `(` (map_char) after select function or method item - auto_select = true, -- automatically select the first item - insert = false, -- use insert confirm behavior instead of replace - map_char = { -- modifies the function or method delimiter by filetypes - all = '(', - tex = '{' - } -}) -------------------- FZF NATIVE ---------------------------- require('telescope').load_extension('fzf') -------------------- TERMINAL ------------------------------ diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua index 0882f4f..0e5c7c5 100644 --- a/lua/cmp_plug.lua +++ b/lua/cmp_plug.lua @@ -105,6 +105,8 @@ cmp.setup.cmdline(':', { -- 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') From c48abe3ad5b258e0bc060ae35dde1e13a8ac6bd3 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 19 Dec 2021 23:13:17 +0100 Subject: [PATCH 107/114] Fixed lsp diagnostic warning --- lua/keymappings.lua | 2 +- lua/my_lspinstall.lua | 2 +- lua/mylsp.lua | 131 ------------------------------------------ 3 files changed, 2 insertions(+), 133 deletions(-) delete mode 100644 lua/mylsp.lua diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 13fc70e..e941744 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -79,7 +79,7 @@ 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 lsp_document_diagnostics') +utils.map('n', 'v', 'Telescope diagnostics bufnr=0') utils.map('n', '', 'Telescope neoclip') utils.map('n', 'j', 'Telescope jumplist') diff --git a/lua/my_lspinstall.lua b/lua/my_lspinstall.lua index 75f59b6..7dd0d40 100644 --- a/lua/my_lspinstall.lua +++ b/lua/my_lspinstall.lua @@ -42,7 +42,7 @@ local on_attach = function(client, bufnr) 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 lsp_document_diagnostics') + utils.map('n', 'v', 'Telescope diagnostics bufnr=0') utils.map('n', '', ':ClangdSwitchSourceHeader', opts) -- Set some keybinds conditional on server capabilities diff --git a/lua/mylsp.lua b/lua/mylsp.lua deleted file mode 100644 index e2c3992..0000000 --- a/lua/mylsp.lua +++ /dev/null @@ -1,131 +0,0 @@ -local nvim_lsp = require 'lspconfig' -local utils = require('utils') - -local system_name -if vim.fn.has("mac") == 1 then - system_name = "macOS" -elseif vim.fn.has("unix") == 1 then - system_name = "Linux" -elseif vim.fn.has('win32') == 1 then - system_name = "Windows" -else - print("Unsupported system for sumneko") -end - -local sumneko_root_path = 'D:/tmp/lua-language-server' -local sumneko_binary = sumneko_root_path.."/bin/"..system_name.."/lua-language-server" --- We use the default settings for ccls and pylsp: the option table can stay empty --- nvim_lsp.ccls.setup {} -nvim_lsp.pyright.setup{} -nvim_lsp.clangd.setup{} -nvim_lsp.cmake.setup{} -nvim_lsp.jsonls.setup{} -nvim_lsp.groovyls.setup{ - -- Unix - cmd = { "java", "-jar", "D:/tmp/groovy-language-server/build/libs/groovy-language-server-all.jar" } -} - --- Add additional capabilities supported by nvim-cmp -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 lsp_document_diagnostics') - 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 - --- Enable some language servers with the additional completion capabilities offered by nvim-cmp -local servers = {'clangd', 'pyright', 'cmake', 'jsonls'} -for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - on_attach = on_attach, - capabilities = capabilities, - } -end - -nvim_lsp.sumneko_lua.setup{ - cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, - on_attach = on_attach, - capabilities = capabilities, -} - -nvim_lsp.groovyls.setup{ - -- Unix - cmd = { "java", "-jar", "D:/tmp/groovy-language-server/build/libs/groovy-language-server-all.jar" }, - on_attach = on_attach, - capabilities = capabilities, -} - -local signs = { Error = " ", Warning = " ", Hint = " ", Information = " " } -for type, icon in pairs(signs) do - local hl = "LspDiagnosticsSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) -end From 89cb317be08242bbadbf0197832dc0876c1c135f Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 19 Dec 2021 23:13:36 +0100 Subject: [PATCH 108/114] Added flake8 --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index d2bb709..6e1524f 100644 --- a/init.lua +++ b/init.lua @@ -184,6 +184,7 @@ null_ls.setup { null_ls.builtins.code_actions.gitsigns, null_ls.builtins.formatting.autopep8, null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.stylua + null_ls.builtins.formatting.stylua, + null_ls.builtins.diagnostics.flake8 } } From ad0ddc735d252ea0a34985b792f43065aae83cb0 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 19 Dec 2021 23:51:17 +0100 Subject: [PATCH 109/114] Added isort nullls and move it to lsp installer file --- init.lua | 10 ---------- lua/my_lspinstall.lua | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/init.lua b/init.lua index 6e1524f..708ac17 100644 --- a/init.lua +++ b/init.lua @@ -178,13 +178,3 @@ require("indent_blankline").setup { context_patterns = {'class', 'function', 'method', 'block', '^if', '^for', '^while'}, } -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 - } -} diff --git a/lua/my_lspinstall.lua b/lua/my_lspinstall.lua index 7dd0d40..0647ab8 100644 --- a/lua/my_lspinstall.lua +++ b/lua/my_lspinstall.lua @@ -92,3 +92,17 @@ lsp_installer.on_server_ready(function(server) 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 +} From 7705b5fc8ac57bc12136549c9ea748283be6fa06 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 19 Dec 2021 23:55:26 +0100 Subject: [PATCH 110/114] Removed unused variables --- init.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/init.lua b/init.lua index 708ac17..343c241 100644 --- a/init.lua +++ b/init.lua @@ -3,10 +3,7 @@ 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 fn = vim.fn - -- Auto install packer.nvim if not exists -local fn = vim.fn 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}) @@ -116,7 +113,6 @@ require('Comment').setup({ }) -------------------- CMAKE --------------------------------- require('telescope').load_extension('cmake') -local Path = require('plenary.path') 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. From ab7f22b9bccd749045239dad4fba1040e5ccfe33 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sun, 19 Dec 2021 23:55:56 +0100 Subject: [PATCH 111/114] Added flake8 config --- .flake8 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .flake8 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 From 472372a5b4b2a164692048ec66ef9ff3922d16c4 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 21 Dec 2021 21:28:32 +0100 Subject: [PATCH 112/114] Removed lightbulb --- init.lua | 4 ---- lua/plugins.lua | 1 - 2 files changed, 5 deletions(-) diff --git a/init.lua b/init.lua index 343c241..2bb3572 100644 --- a/init.lua +++ b/init.lua @@ -63,13 +63,9 @@ require('nvim-treesitter.configs').setup({ -------------------- TELESCOPE ----------------------------- require('my_telescope') -------------------- LSP ----------------------------------- - require('my_lspinstall') -------------------- GITSIGNS ------------------------------ require('gitsigns').setup() --------------------- LIGHTBULB ----------------------------- -require('nvim-lightbulb').update_lightbulb() -vim.cmd [[autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()]] -------------------- CMP ----------------------------------- require('cmp_plug') -------------------- NVIM-TREE ----------------------------- diff --git a/lua/plugins.lua b/lua/plugins.lua index a09ff4a..8c080b3 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -12,7 +12,6 @@ return require('packer').startup(function() use {'lukas-reineke/indent-blankline.nvim'} use {'nvim-lua/plenary.nvim'} use {'lewis6991/gitsigns.nvim'} - use {'kosayoda/nvim-lightbulb'} use { 'kyazdani42/nvim-tree.lua', requires = 'kyazdani42/nvim-web-devicons' From f7c5812c9e42eafe0eca20792bb70948a67785d7 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 21 Dec 2021 21:41:23 +0100 Subject: [PATCH 113/114] Extract options to my_options.lua --- init.lua | 36 +----------------------------------- lua/my_options.lua | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 lua/my_options.lua diff --git a/init.lua b/init.lua index 2bb3572..6f88f84 100644 --- a/init.lua +++ b/init.lua @@ -15,41 +15,7 @@ local utils = require('utils') require('plugins') require('keymappings') -------------------- OPTIONS ------------------------------- -cmd 'colorscheme gruvbox-material' -- Put your favorite colorscheme here -cmd 'syntax enable' -cmd 'filetype plugin indent on' -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) - +require('my_options') -------------------- AUTOCOMMANDS -------------------------- require("autocommands") -------------------- TREE-SITTER --------------------------- 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) From c5646fef8e9d539ae255da52ff23455f4b00b505 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Tue, 21 Dec 2021 21:51:20 +0100 Subject: [PATCH 114/114] Some refactoring --- init.lua | 25 ++++++++----------- lua/{autocommands.lua => my_autocommands.lua} | 0 lua/{cmp_plug.lua => my_cmp.lua} | 0 lua/{keymappings.lua => my_keymappings.lua} | 0 lua/{plugins.lua => my_plugins.lua} | 0 5 files changed, 11 insertions(+), 14 deletions(-) rename lua/{autocommands.lua => my_autocommands.lua} (100%) rename lua/{cmp_plug.lua => my_cmp.lua} (100%) rename lua/{keymappings.lua => my_keymappings.lua} (100%) rename lua/{plugins.lua => my_plugins.lua} (100%) diff --git a/init.lua b/init.lua index 6f88f84..7ad4f77 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,9 @@ 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 @@ -10,14 +12,16 @@ if fn.empty(fn.glob(install_path)) > 0 then vim.cmd 'packadd packer.nvim' end vim.cmd [[packadd packer.nvim]] -local utils = require('utils') --- Install plugins -require('plugins') -require('keymappings') --------------------- OPTIONS ------------------------------- +-------------------- EXTERNAL ------------------------------ +require('my_plugins') +require('my_keymappings') require('my_options') --------------------- AUTOCOMMANDS -------------------------- -require("autocommands") +require("my_autocommands") + +-- plugins +require('my_telescope') +require('my_lspinstall') +require('my_cmp') -------------------- TREE-SITTER --------------------------- require('nvim-treesitter.configs').setup({ ensure_installed = 'maintained', @@ -25,15 +29,8 @@ require('nvim-treesitter.configs').setup({ enable = true } }) - --------------------- TELESCOPE ----------------------------- -require('my_telescope') --------------------- LSP ----------------------------------- -require('my_lspinstall') -------------------- GITSIGNS ------------------------------ require('gitsigns').setup() --------------------- CMP ----------------------------------- -require('cmp_plug') -------------------- NVIM-TREE ----------------------------- require('nvim-tree').setup({ auto_close = true, diff --git a/lua/autocommands.lua b/lua/my_autocommands.lua similarity index 100% rename from lua/autocommands.lua rename to lua/my_autocommands.lua diff --git a/lua/cmp_plug.lua b/lua/my_cmp.lua similarity index 100% rename from lua/cmp_plug.lua rename to lua/my_cmp.lua diff --git a/lua/keymappings.lua b/lua/my_keymappings.lua similarity index 100% rename from lua/keymappings.lua rename to lua/my_keymappings.lua diff --git a/lua/plugins.lua b/lua/my_plugins.lua similarity index 100% rename from lua/plugins.lua rename to lua/my_plugins.lua