From 8b86e7dfd27a65b5c75cde7c1fc0624ab4c59775 Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Wed, 31 Mar 2021 11:02:29 +0200 Subject: [PATCH] onward --- .config/nvim/init.vim | 88 +++++++++++++++++++++++++++++--------- .config/starship-tmux.toml | 2 +- .gitconfig | 2 +- .tmux.conf | 6 ++- .zshrc | 3 +- 5 files changed, 77 insertions(+), 24 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 97e4bfb..d6a1fb6 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -314,36 +314,84 @@ nnoremap g0 lua vim.lsp.buf.document_symbol() nnoremap gW lua vim.lsp.buf.workspace_symbol() nnoremap gd lua vim.lsp.buf.declaration() -:lua << END -require'lspconfig'.gopls.setup{ -} -require'lspconfig'.jdtls.setup{ -} +:lua << EOF +local nvim_lsp = require('lspconfig') +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', '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) + elseif client.resolved_capabilities.document_range_formatting then + buf_set_keymap("n", "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=LightYellow + hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow + hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]], false) + end +end + +-- Use a loop to conveniently both setup defined servers +-- and map buffer local keybindings when the language server attaches +local servers = { "gopls", "jdtls", "vimls", "yamlls" } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { on_attach = on_attach } +end require'lspconfig'.sumneko_lua.setup{ cmd = {"lua-language-server"}; + on_attach = on_attach; } require'lspconfig'.terraformls.setup{ - cmd = {'terraform-ls', 'serve'} + cmd = {'terraform-ls', 'serve'}; + on_attach = on_attach; } +EOF -require'lspconfig'.vimls.setup{ -} +" nmap (completion_smart_tab) +" nmap (completion_smart_s_tab) +" let g:completion_chain_complete_list = [ +" \{'complete_items': ['lsp', 'buffers', 'snippet']}, +" \{'mode': ''}, +" \{'mode': ''} +" \] -require'lspconfig'.yamlls.setup{ -} - -END - -nmap (completion_smart_tab) -nmap (completion_smart_s_tab) -let g:completion_chain_complete_list = [ - \{'complete_items': ['lsp', 'buffers', 'snippet']}, - \{'mode': ''}, - \{'mode': ''} -\] +let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy'] +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" " Use and to navigate through popup menu diff --git a/.config/starship-tmux.toml b/.config/starship-tmux.toml index 97a5f6a..a41637c 100644 --- a/.config/starship-tmux.toml +++ b/.config/starship-tmux.toml @@ -2,11 +2,11 @@ add_newline = false format = """ $status\ -$cmd_duration\ $jobs\ $kubernetes\ $gcloud\ """ +#$cmd_duration\ # $git_branch\ # $git_commit\ # $git_state\ diff --git a/.gitconfig b/.gitconfig index 15ce5fd..231d531 100644 --- a/.gitconfig +++ b/.gitconfig @@ -21,7 +21,7 @@ rebase = true b = branch -va d = diff --stat -p -C ds = diff --staged --stat -p -C -du = !"git --no-pager diff --stat -p -C --color=always | bat" +du = !"git --no-pager diff --stat -p -C --color=always" patch = !git --no-pager diff --no-color co = checkout st = status -sb diff --git a/.tmux.conf b/.tmux.conf index 6960745..2412ba4 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -17,8 +17,9 @@ bind-key ] paste-buffer -p set -g update-environment "XAUTHORITY DISPLAY WINDOWID SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION" set -g default-command zsh -set -g history-limit 50000 +set -g history-limit 100000 +set-option -g default-terminal "xterm-direct" set -ga terminal-overrides ",*:Tc" # true colous support set -as terminal-overrides ',*:sitm=\E[3m' # Italics support for older ncurses set -as terminal-overrides ',*:smxx=\E[9m' # Strikeout @@ -54,6 +55,9 @@ bind C-k clear-history bind -n C-l send-keys C-l \; clear-history bind-key -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 1 scroll-up bind-key -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 1 scroll-down +bind-key / copy-mode \; send-key ? +bind-key P 'capture-pane' \; capture-pane -S - \; save-buffer /tmp/tmux \; delete-buffer +bind-key -n C-\\ copy-mode \; send -X search-backward " % "\; send -X search-again setw -g window-status-format "" setw -g window-status-current-format "" diff --git a/.zshrc b/.zshrc index 22b3ee2..320a550 100644 --- a/.zshrc +++ b/.zshrc @@ -121,6 +121,7 @@ alias tree='exa --tree' alias v=vgrep alias ve='env EDITOR= vgrep -s' alias xc='xclip -selection clipboard' +alias c='cut -c-${COLUMNS}' ## vim @@ -151,7 +152,7 @@ export PATH=$HOME/.krew/bin:$PATH command -v linkerd >/dev/null 2>&1 && source <(linkerd completion zsh) ## Flux -export FLUX_FORWARD_NAMESPACE=flux +command -v flux >/dev/null 2>&1 && source <(flux completion zsh) ## Google Cloud [ -f /opt/google-cloud-sdk/completion.zsh.inc ] && source /opt/google-cloud-sdk/completion.zsh.inc