diff --git a/dot_config/nvim/after/plugin/lsp.lua.tmpl b/dot_config/nvim/after/plugin/lsp.lua.tmpl new file mode 100644 index 0000000..c3343a0 --- /dev/null +++ b/dot_config/nvim/after/plugin/lsp.lua.tmpl @@ -0,0 +1,209 @@ +local ok, lsp = pcall(require, 'lspconfig') +if not ok then + return +end + +{{- if ne .chezmoi.os "openbsd" }} +-- See :help mason-settings +require('mason').setup({ + ui = { border = 'rounded' } +}) + +-- See :help mason-lspconfig-settings +require('mason-lspconfig').setup({ + ensure_installed = { + 'clangd', + 'gopls', + 'ltex', + 'svelte', + 'tsserver', + 'eslint', + 'html', + 'cssls', + 'lua_ls' + } +}) +{{- end }} + +local lsp_defaults = lsp.util.default_config + +lsp_defaults.capabilities = vim.tbl_deep_extend( + 'force', + lsp_defaults.capabilities, + require('cmp_nvim_lsp').default_capabilities() +) + +local sign = function(opts) + -- See :help sign_define() + vim.fn.sign_define(opts.name, { + texthl = opts.name, + text = opts.text, + numhl = '' + }) +end + +sign({ name = 'DiagnosticSignError', text = '✘' }) +sign({ name = 'DiagnosticSignWarn', text = '▲' }) +sign({ name = 'DiagnosticSignHint', text = '⚑' }) +sign({ name = 'DiagnosticSignInfo', text = '' }) + +vim.diagnostic.config({ + virtual_text = false, + severity_sort = true, + float = { + border = 'rounded', + source = 'always', + header = '', + prefix = '', + }, +}) + +vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( + vim.lsp.handlers.hover, + { border = 'rounded' } +) + +vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( + vim.lsp.handlers.signature_help, + { border = 'rounded' } +) + +vim.lsp.handlers["workspace/diagnostic/refresh"] = function(_, _, ctx) + local ns = vim.lsp.diagnostic.get_namespace(ctx.client_id) + pcall(vim.diagnostic.reset, ns) + return true +end + +vim.api.nvim_create_autocmd('BufWritePre', { + pattern = '*.go', + callback = function() + vim.lsp.buf.code_action({ context = { only = { 'source.organizeImports' } }, apply = true }) + end +}) + +require("lsp-format").setup {} + +{{- if ne .chezmoi.os "openbsd" }} +local group = vim.api.nvim_create_augroup('lsp_cmds', { clear = true }) + +vim.api.nvim_create_autocmd('LspAttach', { + group = group, + desc = 'LSP actions', + callback = function(args) + local bufmap = function(mode, lhs, rhs) + local opts = { buffer = true } + vim.keymap.set(mode, lhs, rhs, opts) + end + local client = vim.lsp.get_client_by_id(args.data.client_id) + require("lsp-format").on_attach(client) + + bufmap('n', 'K', 'lua vim.lsp.buf.hover()') + bufmap('n', 'gd', 'lua vim.lsp.buf.definition()') + bufmap('n', 'gD', 'lua vim.lsp.buf.declaration()') + bufmap('n', 'go', 'lua vim.lsp.buf.type_definition()') + bufmap('n', 'gs', 'lua vim.lsp.buf.signature_help()') + bufmap('n', 'gA', 'Telescope diagnostics') + bufmap('n', 'gr', 'Telescope lsp_references') + bufmap('n', 'gi', 'Telescope lsp_implementations') + bufmap('n', '', 'lua vim.lsp.buf.rename()') + bufmap('n', '', 'lua vim.lsp.buf.format({async = true})') + bufmap('n', '', 'lua vim.lsp.buf.code_action()') + bufmap('x', '', 'lua vim.lsp.buf.range_code_action()') + bufmap('n', 'gl', 'lua vim.diagnostic.open_float()') + bufmap('n', '[d', 'lua vim.diagnostic.goto_prev()') + bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') + end +}) + +require('mason-lspconfig').setup_handlers({ + function(server) + lsp[server].setup({}) + end, + ['tsserver'] = function() + lsp.tsserver.setup({ + settings = { + completions = { + completeFunctionCalls = true + } + } + }) + end, + ['lua_ls'] = function() + lsp.lua_ls.setup({ + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + }, + } + } + }) + end, + ['gopls'] = function() + lsp.gopls.setup({ + settings = { + gopls = { + analyses = { + unusedparams = true, + unusedvariable = true, + shadow = true + }, + staticcheck = true, + }, + } + }) + end, +}) +{{- else }} +local on_attach = function(client) + local bufmap = function(mode, lhs, rhs) + local opts = {buffer = true} + vim.keymap.set(mode, lhs, rhs, opts) + end + require("lsp-format").on_attach(client) + + bufmap('n', 'K', 'lua vim.lsp.buf.hover()') + bufmap('n', 'gd', 'lua vim.lsp.buf.definition()') + bufmap('n', 'gD', 'lua vim.lsp.buf.declaration()') + bufmap('n', 'go', 'lua vim.lsp.buf.type_definition()') + bufmap('n', 'gs', 'lua vim.lsp.buf.signature_help()') + bufmap('n', 'gA', 'Telescope diagnostics') + bufmap('n', 'gr', 'Telescope lsp_references') + bufmap('n', 'gi', 'Telescope lsp_implementations') + bufmap('n', '', 'lua vim.lsp.buf.rename()') + bufmap('n', '', 'lua vim.lsp.buf.format({async = true})') + bufmap('n', '', 'lua vim.lsp.buf.code_action()') + bufmap('x', '', 'lua vim.lsp.buf.range_code_action()') + bufmap('n', 'gl', 'lua vim.diagnostic.open_float()') + bufmap('n', '[d', 'lua vim.diagnostic.goto_prev()') + bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') +end + +lsp.gopls.setup { + settings = { + gopls = { + analyses = { + unusedparams = true, + unusedvariable = true, + shadow = true + }, + staticcheck = true, + }, + }, + on_attach = on_attach +} +lsp.clangd.setup { on_attach = on_attach } +lsp.ltex.setup { on_attach = on_attach } +lsp.svelte.setup { on_attach = on_attach } +lsp.tsserver.setup { on_attach = on_attach } +lsp.lua_ls.setup { + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + }, + } + }, + on_attach = on_attach +} +{{- end }} diff --git a/dot_tmux.conf.tmpl b/dot_tmux.conf.tmpl index aab2243..fc0bcd9 100644 --- a/dot_tmux.conf.tmpl +++ b/dot_tmux.conf.tmpl @@ -47,7 +47,8 @@ set -g display-time 4000 set -g status-interval 5 # upgrade $TERM -set -g default-terminal "{{ .term }}" +set -g default-terminal "screen-256color" +set-option -sa terminal-features ',{{ .term }}:RGB' # emacs key bindings in tmux command prompt (prefix + :) are better than # vi keys, even for vim users diff --git a/dot_vimrc.tmpl b/dot_vimrc.tmpl index 8dc341b..0c63bfd 100644 --- a/dot_vimrc.tmpl +++ b/dot_vimrc.tmpl @@ -9,8 +9,6 @@ let maplocalleader = "\\" map let g:elite_mode=1 -source ~/.vim/local.vim - " Plugins {{ "{{{" }} call plug#begin('~/.vim/plugged') "########### @@ -400,7 +398,6 @@ set thesaurus=~/.vim/thesaurus/english.txt set spellfile=~/.vim/spell/en.utf8.add set spelllang=en_us -set diffopt+=algorithm:patience set diffopt+=vertical " hi SpellBad gui=underline guifg=red cterm=underline ctermfg=red "{{ "}}}" }} diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 02f83ad..ad18165 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -73,8 +73,8 @@ alias bkp-etc='doas restic -r /mnt/nfs/BSD/restic-repo --verbose backup /etc' alias bkp-list='doas restic -r /mnt/nfs/BSD/restic-repo snapshots' {{- else }} source $HOME/perl5/perlbrew/etc/bashrc -export PATH=$HOME/local/bin:$GOPATH/bin:$HOME/.cargo/bin:$HOME/.symfony/bin:$PATH -{{- if eq .chezmoi.hostname "rohan" }} +export PATH=$HOME/local/bin:$GOPATH/bin:$PATH +{{- if eq .chezmoi.arch "arm64" }} export PATH=/opt/homebrew/bin:$PATH {{- else }} export PATH=/usr/local/opt/sqlite/bin:/usr/local/opt/ruby/bin:/usr/local/opt/mariadb@10.4/bin:$PATH diff --git a/private_dot_msmtprc.tmpl b/private_dot_msmtprc.tmpl new file mode 100644 index 0000000..7ed10ba --- /dev/null +++ b/private_dot_msmtprc.tmpl @@ -0,0 +1,21 @@ +defaults +auth on +tls on +tls_trust_file /etc/ssl/cert.pem +logfile ~/.msmtp.log + +account moebius +host mail.moebiusband.org +port 587 +user jan +password {{ (keepassxc "moebiusband.org").Password }} +from jan@moebiusband.org + +account fau +host groupware.fau.de +port 587 +user unrz254 +password {{ (keepassxc "IDM FAU").Password }} +from jan.eitzinger@fau.de + +account default : moebius