nvim and tmux config

This commit is contained in:
Daniel Lundin 2021-07-22 10:32:46 +02:00
parent 5f5e10b73d
commit bc77f74e5a
10 changed files with 146 additions and 39 deletions

View file

@ -13,14 +13,14 @@ tmux:
styles:
clear: '#[fg=default]'
state: '#[bg=red,fg=white]'
branch: '#[fg=#9ccc65,bg=#1b5e20] '
branch: '#[fg=#9ccc65,bg=#2E7D32] '
remote: '#[fg=cyan]'
staged: '#[fg=green]'
conflict: '#[fg=red]'
modified: '#[fg=#fdd835,bg=#1b5e20]'
untracked: '#[fg=#ff7043,bg=#1b5e20]'
modified: '#[fg=#fdd835,bg=#2E7D32]'
untracked: '#[fg=#ff7043,bg=#2E7D32]'
stashed: '#[fg=#ffcdd2]'
clean: '#[fg=#4caf50,bg=#1b5e20]'
clean: '#[fg=#4caf50,bg=#2E7D32]'
layout: [branch, divergence, ' ', flags, '#[fg=#212121]▕']
options:
branch_max_len: 0

View file

@ -1,5 +1,8 @@
lua require("init")
set title
set titlestring=%F%m\ %r\ %y
function s:recompile_plugins()
luafile %
PackerCompile

View file

@ -42,15 +42,14 @@ vim.fn.sign_define(
local on_attach = function()
require("folding").on_attach()
require "lsp_signature".on_attach() -- Note: add in lsp client on-attach
end
-- simple setups --
local servers = {
"bashls",
"cssls",
"dockerls",
"gopls",
"html",
"jsonls",
-- "sql",
"sumneko_lua",
@ -105,6 +104,25 @@ local yaml_is_k8s = function(bufnr)
return false
end
lspconfig.cssls.setup {
cmd = { "css-languageserver", "--stdio" },
filetypes = { "css" },
settings = {}
}
lspconfig.html.setup {
cmd = { "vscode-html-languageserver", "--stdio" },
filetypes = { "html" },
init_options = {
configurationSection = { "html", "css", "javascript" },
embeddedLanguages = {
css = true,
javascript = true,
}
},
settings = {}
}
lspconfig.yamlls.setup {
settings = {
yaml = {
@ -148,3 +166,72 @@ lspconfig.yamlls.setup {
}
}
}
-- npm install -g typescript typescript-language-server
require'lspconfig'.tsserver.setup({
on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = false
on_attach(client)
require'lsp_signature'.on_attach({
bind = false, -- This is mandatory, otherwise border config won't get registered.
-- If you want to hook lspsaga or other signature handler, pls set to false
doc_lines = 2, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated);
-- set to 0 if you DO NOT want any API comments be shown
-- This setting only take effect in insert mode, it does not affect signature help in normal
-- mode, 10 by default
floating_window = true, -- show hint in a floating window, set to false for virtual text only mode
fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters
hint_enable = false, -- virtual hint enable
hint_prefix = "🐼 ", -- Panda for parameter
hint_scheme = "String",
use_lspsaga = true, -- set to true if you want to use lspsaga popup
hi_parameter = "Search", -- how your parameter will be highlight
max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down
-- to view the hiding contents
max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width
handler_opts = {
border = "single" -- double, single, shadow, none
},
extra_trigger_chars = {} -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
})
local ts_utils = require("nvim-lsp-ts-utils")
ts_utils.setup {
debug = false,
disable_commands = false,
enable_import_on_completion = false,
import_all_timeout = 5000, -- ms
-- eslint
eslint_enable_code_actions = true,
eslint_enable_disable_comments = true,
eslint_bin = 'eslint_d',
eslint_config_fallback = nil,
eslint_enable_diagnostics = true,
-- formatting
enable_formatting = true,
formatter = 'prettier',
formatter_config_fallback = nil,
-- parentheses completion
complete_parens = false,
signature_help_in_parens = false,
-- update imports on file move
update_imports_on_move = true,
require_confirmation_on_move = true,
watch_dir = nil,
}
ts_utils.setup_client(client)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<Leader>co", ":TSLspOrganize<CR>", { silent = true })
vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent<CR>", { silent = true })
vim.api.nvim_buf_set_keymap(bufnr, "n", "<Leader>cR", ":TSLspRenameFile<CR>", { silent = true })
vim.api.nvim_buf_set_keymap(bufnr, "n", "<Leader>ci", ":TSLspImportAll<CR>", { silent = true })
end
})

View file

@ -7,8 +7,9 @@ telescope.setup {
defaults = {
layout_strategy = "flex",
-- layout_defaults = {flip_columns = 160},
preview_cutoff = 10,
results_height = 10,
layout_config = {
preview_cutoff = 10,
},
mappings = {
i = {
["<CR>"] = actions.select_default + actions.center,

View file

@ -2,7 +2,6 @@ vim.cmd[[set undofile]]
vim.cmd[[set completeopt-=preview]]
vim.cmd[[set viewoptions-=options]]
vim.g.mapleader = ','
vim.o.clipboard = 'unnamed'
vim.o.hidden = true
vim.o.mouse = 'a'
vim.o.splitbelow = true

View file

@ -3,6 +3,8 @@ return require('packer').startup(function()
use 'pierreglaser/folding-nvim'
use 'tjdevries/colorbuddy.vim'
use 'wbthomason/packer.nvim'
use 'ray-x/lsp_signature.nvim'
use 'jose-elias-alvarez/nvim-lsp-ts-utils'
use {
'b3nj5m1n/kommentary',
@ -72,7 +74,7 @@ return require('packer').startup(function()
use {
"lukas-reineke/indent-blankline.nvim",
branch = "lua",
branch = "master",
config = function()
-- vim.wo.colorcolumn = "100"
vim.g.indent_blankline_char = ""
@ -122,10 +124,12 @@ return require('packer').startup(function()
map('n', '<space>', '<cmd>lua require("telescope.builtin").oldfiles()<CR>')
map('n', '<leader>e', '<cmd>lua require("telescope.builtin").git_files()<CR>')
map('n', '<leader>g', '<cmd>lua require("telescope.builtin").git_status()<CR>')
map('n', '<leader>a', '<cmd>lua require("telescope.builtin").lsp_code_actions()<CR>')
map('n', '<leader>s', '<cmd>lua require("telescope.builtin").lsp_document_symbols()<CR>')
map('n', '<leader>t', '<cmd>lua require("telescope.builtin").treesitter()<CR>')
map('n', '<leader>/', '<cmd>lua require("telescope.builtin").live_grep()<CR>')
map('n', '<leader>.', '<cmd>lua require("telescope.builtin").file_browser()<CR>')
map('n', '<leader>p', '<cmd>lua require("telescope.builtin").registers()<CR>')
map('n', 'gr', '<cmd>lua require("telescope.builtin").lsp_references()<CR>')
map('n', 'gd', '<cmd>lua require("telescope.builtin").lsp_definitions()<CR>')
map('n', 'g/', '<cmd>lua require("telescope.builtin").lsp_document_symbols()<CR>')
@ -149,6 +153,18 @@ return require('packer').startup(function()
end
}
use {
"ray-x/go.nvim",
config = function()
require('go').setup({
comment_placeholder = ''
})
vim.cmd("autocmd FileType go nmap <Leader>c :lua require('go.comment').gen()<cr>")
vim.cmd("autocmd BufWritePre *.go :silent! lua require('go.format').gofmt()")
vim.cmd('autocmd BufWritePre (InsertLeave?) <buffer> lua vim.lsp.buf.formatting_sync(nil,500)')
end
}
use {
"onsails/lspkind-nvim",
config = function()
@ -165,7 +181,7 @@ return require('packer').startup(function()
end
}
--[[ use {
use {
"cuducos/yaml.nvim",
ft = {"yaml"},
requires = {
@ -176,5 +192,4 @@ return require('packer').startup(function()
require("yaml_nvim").init()
end
}
]]
end)

View file

@ -1,12 +1,8 @@
add_newline = false
format = """\
$hostname\
$directory\
$git_branch\
$git_status\
$git_state\
( $character)\
($character)\
"""
[character]

View file

@ -101,6 +101,7 @@ signingkey = 79020DB026385D4C
[init]
defaultBranch = main
[url "git@github.com:"]
insteadOf = https://github.com/
insteadOf = https://github.com/

View file

@ -19,7 +19,7 @@ set -g update-environment "XAUTHORITY DISPLAY WINDOWID SSH_ASKPASS SSH_AGENT_PID
set -g default-command zsh
set -g history-limit 100000
set-option -g default-terminal "tmux-direct"
set-option -g default-terminal "tmux"
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
@ -64,11 +64,11 @@ bind-key -n C-\\ copy-mode \; send -X search-backward " % "\; send -X search-aga
setw -g window-status-format ""
setw -g window-status-current-format ""
setw -g window-status-separator ""
set -g status-style "bg=#3e3e3e,fg=#c0c0c0"
set -g status-style "bg=#f0f0f0,fg=#000000"
set -g status-left-length 0
set -g status-right-length 0
set -g status-left '#{?#{==:#W,1},  #T,#[bg=#263238,fg=#707070] #W#[fg=#212121]▕#[bg=#3e3e3e,fg=#a0a0a0] #{=|145|…:pane_current_path}}'
set -g status-right '#{?#{==:#W,1},,#[fg=#f7f7f7]#{@starship}#[fg=#212121]▕#[fg=#f7f7f7]#(~/go/bin/gitmux -cfg ~/.config/gitmux/gitmux.yaml "#{pane_current_path}")}#[bg=#263238,fg=#707070] #(date +%%H:%%M) '
set -g status-left '#{?#{==:#I,1},#[bg=#99aabb]  #[bg=#ccddee]#[fg=#445566] #T #[fg=#ccddee]#[bg=#f0f0f0]🭬,#[bg=#cccccc,fg=#ffffff] #I#[fg=#fcfcfc]▕#[bg=#f0f0f0,fg=#777777] #{=|145|…:pane_current_path}}'
set -g status-right '#{?#{==:#I,1},,#[fg=#07f7f7]#{@starship}#[fg=#fcfcfc]▕#[fg=#f7f7f7]#(~/go/bin/gitmux -cfg ~/.config/gitmux/gitmux.yaml "#{pane_current_path}")}#[bg=#cccccc,fg=#ffffff] #(date +%%H:%%M) '
set -g set-titles on
set -g set-titles-string "#H - #T"

41
.zshrc
View file

@ -5,8 +5,6 @@ zplug "plugins/git", from:oh-my-zsh
zplug "zsh-users/zsh-completions"
zplug 'zsh-users/zsh-syntax-highlighting', defer:2
zplug 'zsh-users/zsh-history-substring-search', defer:3
# zplug 'zsh-users/zsh-autosuggestions'
# zplug 'Aloxaf/fzf-tab'
if ! zplug check --verbose; then
printf "Install? [y/N]: "
@ -44,10 +42,6 @@ setopt extended_glob
setopt ksh_glob
setopt null_glob
# ## Completion
autoload -Uz compinit
compinit
## Autosuggest
# ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#D7CCC8,italic"
# ZSH_AUTOSUGGEST_USE_ASYNC=1
@ -134,7 +128,7 @@ export NVIM_LISTEN_ADDRESS=/tmp/nvimsocket
e ()
{
nvr --nostart --remote $(readlink -f "$@")
echo -e "\x1b]2;$(_title) $(date +%s):nvim\x1b\\"
tmux select-window -t1
}
## fzf
@ -152,19 +146,29 @@ command -v kubectl >/dev/null 2>&1 && source <(kubectl completion zsh)
export PATH=$HOME/.krew/bin:$PATH
## linkerd
command -v linkerd >/dev/null 2>&1 && source <(linkerd completion zsh)
if [ ! -f "${fpath[1]}/_linkerd" ]; then
command -v linkerd >/dev/null 2>&1 && linkerd completion zsh > "${fpath[1]}/_linkerd"
fi
## Flux
command -v flux >/dev/null 2>&1 && source <(flux completion zsh)
if [ ! -f "${fpath[1]}/_flux" ]; then
command -v flux >/dev/null 2>&1 && source <(flux completion zsh)
fi
## Tekton cli
command -v tkn >/dev/null 2>&1 && source <(tkn completion zsh)
if [ ! -f "${fpath[1]}/_tkn" ]; then
command -v tkn >/dev/null 2>&1 && tkn completion zsh > "${fpath[1]}/_tkn"
fi
## kapp
command -v kapp >/dev/null 2>&1 && source <(kapp completion zsh)
if [ ! -f "${fpath[1]}/_kapp" ]; then
command -v kapp >/dev/null 2>&1 && kapp completion zsh --tty=false > "${fpath[1]}/_kapp"
fi
## talos cli
command -v talosctl >/dev/null 2>&1 && source <(talosctl completion zsh)
if [ ! -f "${fpath[1]}/_talosctl" ]; then
command -v talosctl >/dev/null 2>&1 && talosctl completion zsh > "${fpath[1]}/_talosctl"
fi
## Google Cloud
[ -f /opt/google-cloud-sdk/completion.zsh.inc ] && source /opt/google-cloud-sdk/completion.zsh.inc
@ -172,14 +176,16 @@ command -v talosctl >/dev/null 2>&1 && source <(talosctl completion zsh)
# hack until gcloud works with python 3.9
export CLOUDSDK_PYTHON=python2
## Golang
export PATH=$HOME/go/bin:$PATH
GOPROXY=https://proxy.golang.org/
GOPROXY=https://athens.aarn.shelman.io
## Ansible
export ANSIBLE_NOCOWS=1
## Docker
export DOCKER_BUILDKIT=1
## PostgreSQL Operator
export PATH=/home/dln/.pgo/pgo:$PATH
@ -193,8 +199,7 @@ export PGO_NAMESPACE=pgo
export PATH=$HOME/bin:$PATH
#autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /usr/bin/vault vault
# ## Completion
autoload -Uz compinit
compinit
compinit -i