From 64d19effcc7aa1db2f134130484aa68cddd6ecd6 Mon Sep 17 00:00:00 2001 From: "jakob.stendahl" Date: Thu, 30 Jun 2022 13:31:26 +0200 Subject: neovim --- .gitignore | 2 + Common/i3/Xresources | 6 +- Common/i3/config/i3/config | 10 +- Common/i3/config/i3status/config | 5 +- Common/nvim/after/ftplugin/vhdl.lua | 3 + Common/nvim/init.lua | 3 + Common/nvim/init.vim | 3 - Common/nvim/lua/basic.lua | 239 +++++++++++++++++++++++++++++++ Common/nvim/lua/helper_functions.lua | 72 ++++++++++ Common/nvim/lua/plugins.lua | 25 ++++ Common/p10k.zsh | 21 ++- Common/powerline_config/powerline_config | 1 + Common/vimrc | 9 +- Common/zshrc | 2 +- linux/tmux.conf | 3 +- 15 files changed, 376 insertions(+), 28 deletions(-) create mode 100644 Common/nvim/after/ftplugin/vhdl.lua create mode 100644 Common/nvim/init.lua delete mode 100644 Common/nvim/init.vim create mode 100644 Common/nvim/lua/basic.lua create mode 100644 Common/nvim/lua/helper_functions.lua create mode 100644 Common/nvim/lua/plugins.lua create mode 120000 Common/powerline_config/powerline_config diff --git a/.gitignore b/.gitignore index 7fda8f9..29566af 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,5 @@ node_modules Common/vim/plugged/ Common/vim/autoload/ Common/vim/vim + +Common/nvim/plugin/ diff --git a/Common/i3/Xresources b/Common/i3/Xresources index 977fc97..d10c8a9 100755 --- a/Common/i3/Xresources +++ b/Common/i3/Xresources @@ -3,8 +3,10 @@ ! ------------------------------------------------------------------------------ ! special -*.foreground: #d8dee8 -*.background: #2f343f +!*.foreground: #d8dee8 +*.foreground: #e5e9f0 +!*.background: #2f343f +*.background: #121212 *.cursorColor: #b48ead ! black diff --git a/Common/i3/config/i3/config b/Common/i3/config/i3/config index 5c32cad..c71fa85 100644 --- a/Common/i3/config/i3/config +++ b/Common/i3/config/i3/config @@ -13,6 +13,9 @@ floating_modifier $super #exec --no-startup-id feh --bg-scale ~/.wallpaper.png exec --no-startup-id wallpaper.sh exec --no-startup-id compton --xrender-sync-fence --xrender-sync -b +exec --no-startup-id /usr/lib/gsd-xsettings +exec_always --no-startup-id gnome-power-manager +exec --no-startup-id gnome-flashback exec --no-startup-id "~/.config/umon/wallpaper.sh" @@ -108,7 +111,8 @@ bindsym $super+Shift+9 move container to workspace 9 bindsym $super+Shift+r restart # exit i3 -bindsym $super+l exec i3lock -f -c 63bfb6 #-i /home/jakob/.lockscreen.png +#bindsym $super+l exec i3lock -f -c 63bfb6 #-i /home/jakob/.lockscreen.png +bindsym $super+l exec dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock bindsym $super+Shift+e exec "i3-nagbar -t warning -m 'Really, exit?' -b 'Yes' 'i3-msg exit'" bindsym $super+p exec --no-startup-id ~/.config/rofi/bin/applet_powermenu @@ -176,8 +180,8 @@ client.background $blue gaps inner 7 # Keybinds for lenovo x1 carbon -bindsym XF86MonBrightnessUp exec --no-startup-id "brightness-popup.sh inc" -bindsym XF86MonBrightnessDown exec --no-startup-id "brightness-popup.sh dec" +bindsym XF86MonBrightnessUp exec --no-startup-id "/home/jakob/bin/brightness-popup.sh inc" +bindsym XF86MonBrightnessDown exec --no-startup-id "/home/jakob/bin/brightness-popup.sh dec" bindsym XF86Display exec --no-startup-id "arandr" bindsym Print exec --no-startup-id "gnome-screenshot --interactive" diff --git a/Common/i3/config/i3status/config b/Common/i3/config/i3status/config index b3256a2..b129807 100644 --- a/Common/i3/config/i3status/config +++ b/Common/i3/config/i3status/config @@ -67,7 +67,8 @@ battery 0 { } tztime local { - format = " %time " - format_time = " %a %-d %b %H:%M" + #format = " %time " + #format_time = " %a %-d %b %H:%M" + format = "  %a %-d %b %H:%M " } diff --git a/Common/nvim/after/ftplugin/vhdl.lua b/Common/nvim/after/ftplugin/vhdl.lua new file mode 100644 index 0000000..7744755 --- /dev/null +++ b/Common/nvim/after/ftplugin/vhdl.lua @@ -0,0 +1,3 @@ +vim.opt.shiftwidth = 2 +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 diff --git a/Common/nvim/init.lua b/Common/nvim/init.lua new file mode 100644 index 0000000..ee75788 --- /dev/null +++ b/Common/nvim/init.lua @@ -0,0 +1,3 @@ +require("helper_functions") +require("basic") +require('plugins') diff --git a/Common/nvim/init.vim b/Common/nvim/init.vim deleted file mode 100644 index f182e5b..0000000 --- a/Common/nvim/init.vim +++ /dev/null @@ -1,3 +0,0 @@ -set runtimepath^=~/.vim runtimepath+=~/.vim/after -let &packpath = &runtimepath -source ~/.vimrc diff --git a/Common/nvim/lua/basic.lua b/Common/nvim/lua/basic.lua new file mode 100644 index 0000000..16e9a62 --- /dev/null +++ b/Common/nvim/lua/basic.lua @@ -0,0 +1,239 @@ +--[[ +General +--]] + +-- Lines of history +vim.opt.history = 500 +-- Line numbers +vim.opt.nu = true + +-- Autoread when file is changed outside vim +vim.opt.autoread = true + +-- enable filetype plugins +vim.cmd [[ + filetype plugin on + filetype indent on +]] + +-- Use a mapleader +--vim.opt.mapleader = "," +vim.g.mapleader = "," + +-- Fast saving +map('n', 'w', ':w!', silentnoremap) + +-- Convenient sudo saving of file +vim.api.nvim_create_user_command( + 'W', 'w !sudo tee % > /dev/null', + {bang=true, desc='Save file using sudo'} +) + +--[[ +VIM User interface +--]] + +-- Set 7 lines to the cursor - when moving vertically using j/k +vim.opt.so = 7 + +-- set WildMenu +vim.opt.wildmenu = true + +-- Ignore compiled files +vim.opt.wildignore = '*.o,*~,*.pyc' +vim.opt.wildignore:append('*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store') + +-- Always show current position +vim.opt.ruler = true + +-- Hide buffers when they are abandoned +vim.opt.hid = true + +-- Make backspace function normally +vim.opt.backspace = 'eol,start,indent' +vim.opt.whichwrap:append('<,>,h,l') + +-- Ignore case when searching +vim.opt.ignorecase = true + +-- Be smart about cases when searching +-- If search has uppercases, then we want to respect case +vim.opt.smartcase = true + +-- Highlight search results +vim.opt.hlsearch = true + +-- Make search act like search in modern browsers +vim.opt.incsearch = true + +-- Turn on "magic" for regular expressions +vim.opt.magic = true + +-- Show matching brackets when cursor is over one +vim.opt.showmatch = true +vim.opt.mat = 2 + +-- Turn off annoying bells aon errors +--vim.opt.noerrorbells = false +--vim.opt.novisualbell = false +--vim.opt.t_vb = '' +--vim.opt.tm = 500 + +-- Add extra margin to the left (makes changing margins less annoying +vim.opt.foldcolumn = '1' + +-- Show leader commands +vim.opt.showcmd = true + +-- Show colour column +vim.opt.colorcolumn = '80,120' + +-- => Colors and Fonts + +-- Enable syntac highlighting +vim.opt.syntax = 'enable' + +-- Set utf8 as standard encoding +vim.opt.encoding = 'utf8' + +-- Use Unix as the standard file type +vim.opt.ffs = 'unix,dos,mac' + +--[[ +Files, backups and undo +--]] +vim.opt.swapfile = false + +--[[ +Text, tab and indent related +--]] + +-- Use spaces instead of tabs +vim.opt.expandtab = true + +-- Be smart when using tabs +vim.opt.smarttab = true + +-- 1 tab is 4 spaces +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 + +-- Linebreak on 500 ch +vim.opt.lbr = true +vim.opt.tw = 500 + +-- Auto indent +vim.opt.ai = true +-- Smart indent +vim.opt.si = true +-- Wrap lines +vim.opt.wrap = true + +--[[ +Visual mode related +--]] +map('v', ' *', ':call VisualSelection("","")/=@/', silentnoremap) +map('v', ' #', ':call VisualSelection("","")?=@/', silentnoremap) + +--[[ +Moving around, tabs, windows and buffers +--]] +-- Disable highlight when is pressed +map('n', '', ':noh', silentnoremap) + +-- Smart way to move between windows +map('n', '', 'j', silentnoremap) +map('n', '', 'k', silentnoremap) +map('n', '', 'h', silentnoremap) +map('n', '', 'l', silentnoremap) + +-- Close current buffer +map('n', 'bd', ':Bclose:tabclosegT', silentnoremap) +-- Close all buffers +map('n', 'ba', ':bufdo bd', silentnoremap) +-- Navigate buffers +map('n', 'l', ':bnext', silentnoremap) +map('n', 'h', ':bprevious', silentnoremap) + +-- Tab commands +map('n', 'tn', ':tabnew', silentnoremap) +map('n', 'to', ':tabonly', silentnoremap) +map('n', 'tc', ':tabclose', silentnoremap) +map('n', 'tm', ':tabmove', silentnoremap) +map('n', 't', ':tabnext', silentnoremap) + +-- Switch CWD to directory of the open buffer +map('n', 'cd', ':cd %:p:h:pwd 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif +]] + +-- Make mouse work nice with tmux +vim.opt.mouse = 'a' + +--[[ +Status Line +--]] + +-- Always show status line +vim.opt.laststatus = 2 + +--[[ +Mappings +--]] + +-- Move a line of text using ALT+[jk] +map('n', '', 'mz:m+`z', silentnoremap) +map('n', '', 'mz:m-2`z', silentnoremap) +map('v', '', ":m'>+`mzgv`yo`z", silentnoremap) +map('v', '', ":m'<-2`>my`', '', silentnoremap) + map('n', '', '', silentnoremap) + map('v', '', '', silentnoremap) + map('v', '', '', silentnoremap) +end + +-- Delete trailing whitespace on save +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = { "*" }, + command = [[%s/\s\+$//e]] +}) + +--[[ +Misc +--]] + +-- Scribble buffer +map('n', 'q', ':e ~/buffer', silentnoremap) + +-- Toggle paste mode +map('n', 'pp', ':setlocal paste!', silentnoremap) + +-- Send file-title to tmux +vim.opt.titlestring = [[%f %h%m%r%w%{v:progname} (%{tabpagenr()} of %{tabpagenr('$')}})]] +vim.opt.title = true + +-- Toggle displaying special characters +vim.keymap.set('n', '', ToggleListChars, silentnoremap) + +-- Load and save session +map('n', 'sm', ':mksession! vim_session.vim', silentnoremap) +map('n', 'sl', ':source vim_session.vim', silentnoremap) + +-- Dont't close window when deleting buffer +--vim.api.nvim_create_user_command("Bclose", +-- "BufcloseCloseIt()", +-- {bang = true} +--) diff --git a/Common/nvim/lua/helper_functions.lua b/Common/nvim/lua/helper_functions.lua new file mode 100644 index 0000000..cac6c00 --- /dev/null +++ b/Common/nvim/lua/helper_functions.lua @@ -0,0 +1,72 @@ +-- opts that replicate the nore part of noremap +silentnoremap = { noremap = true, silent = true } + +-- Just to make the map function "shorter" +function map(kind, lhs, rhs, opts) + vim.api.nvim_set_keymap(kind, lhs, rhs, opts) +end + +-- True if Paste Mode is enabled +function HasPaste() + return vim.opt.paste:get() and 'PASTE MODE ' or '' +end +vim.api.nvim_create_user_command('HasPaste', HasPaste, {bang=true, desc='Returns a string with PASTE MODE if paste is on.'}) + +-- Toggles wether special characters are visible +list_chars_enabled = false +list_chars_when_enabled = "tab:→ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:»" +function ToggleListChars() + list_chars_enabled = not list_chars_enabled + vim.opt.list = list_chars_enabled + vim.opt.listchars = list_chars_enabled and list_chars_when_enabled or 'eol:$' +end + +-- Close buffer without closing window +--[[ +vim.cmd [[ + function! BufcloseCloseIt() + let l:currentBufNum = bufnr("%") + let l:alternateBufNum = bufnr("#") + + if buflisted(l:alternateBufNum) + buffer # + else + bnext + endif + + if bufnr("%") == l:currentBufNum + new + endif + + if buflisted(l:currentBufNum) + execute("bdelete! ".l:currentBufNum) + endif + endfunction +]] +--]] + +vim.cmd [[ + function! CmdLine(str) + exe "menu Foo.Bar :" . a:str + emenu Foo.Bar + unmenu Foo + endfunction + + + function! VisualSelection(direction, extra_filter) range + let l:saved_reg = @" + execute "normal! vgvy" + + let l:pattern = escape(@", "\\/.*'$^~[]") + let l:pattern = substitute(l:pattern, "\n$", "", "") + + if a:direction == 'gv' + call CmdLine("Ack '" . l:pattern . "' " ) + elseif a:direction == 'replace' + call CmdLine("%s" . '/'. l:pattern . '/') + endif + + let @/ = l:pattern + let @" = l:saved_reg + endfunction +]] diff --git a/Common/nvim/lua/plugins.lua b/Common/nvim/lua/plugins.lua new file mode 100644 index 0000000..43f63a7 --- /dev/null +++ b/Common/nvim/lua/plugins.lua @@ -0,0 +1,25 @@ +-- Autoinstall packer +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 + packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) +end + +-- Autocompile packer +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerCompile + augroup end +]]) + +return require('packer').startup(function(use) + use 'neovim/nvim-lspconfig' -- Easy LSP configuration + use 'kabouzeid/nvim-lspinstall' -- Install LSP servers on demand with :LSPInstall + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if packer_bootstrap then + require('packer').sync() + end +end) diff --git a/Common/p10k.zsh b/Common/p10k.zsh index a2f9cb2..d023f73 100644 --- a/Common/p10k.zsh +++ b/Common/p10k.zsh @@ -163,17 +163,17 @@ # Separator between same-color segments on the right. typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='%242F\u2571' # Separator between different-color segments on the left. - typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0BC' + typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='' # Separator between different-color segments on the right. - typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0BA' + typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='' # The right end of left prompt. - typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0BC' + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='▓▒░' # The left end of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\uE0BA' + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='░▒▓' # The left end of left prompt. - typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL='' + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL='░▒▓' # The right end of right prompt. - typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL='' + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL='▓▒░' # Left prompt terminator for lines without any segments. typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= @@ -408,7 +408,7 @@ # Display the current Git commit if there is no branch and no tag. # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. @@ -416,11 +416,6 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - # ⇣42 if behind the remote. (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. @@ -1216,7 +1211,7 @@ #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Show kubecontext only when the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern' + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile' # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. diff --git a/Common/powerline_config/powerline_config b/Common/powerline_config/powerline_config new file mode 120000 index 0000000..68a45ea --- /dev/null +++ b/Common/powerline_config/powerline_config @@ -0,0 +1 @@ +/home/jakob/_code/dotfiles/Common/powerline_config \ No newline at end of file diff --git a/Common/vimrc b/Common/vimrc index b2ecbff..098db18 100644 --- a/Common/vimrc +++ b/Common/vimrc @@ -184,7 +184,7 @@ set noswapfile set expandtab " Be smart when using tabs ;) -set smarttab +" set smarttab " 1 tab == 4 spaces set shiftwidth=4 @@ -243,7 +243,7 @@ map tn :tabnew map to :tabonly map tc :tabclose map tm :tabmove -map t :tabnext +map t :tabnext " Let 'tl' toggle between this and the last accessed tab let g:lasttab = 1 @@ -451,7 +451,6 @@ Plug 'junegunn/fzf.vim' Plug 'terryma/vim-multiple-cursors' Plug 'preservim/nerdcommenter' Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'dense-analysis/ale' Plug 'evanleck/vim-svelte', {'branch': 'main'} Plug 'preservim/tagbar' Plug 'evanleck/vim-svelte', {'branch': 'main'} @@ -460,6 +459,7 @@ Plug 'christoomey/vim-tmux-navigator' Plug 'tpope/vim-dotenv' Plug 'kristijanhusak/vim-dadbod-ui' Plug 'zivyangll/git-blame.vim' +Plug 'smithbm2316/centerpad.nvim' "Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'} "Plug 'clangd/coc-clangd', {'do': 'yarn install --frozen-lockfile'} @@ -472,6 +472,7 @@ Plug 'zivyangll/git-blame.vim' "Plug 'fannheyward/coc-pyright', {'do': 'yarn install --frozen-lockfile'} "Plug 'josa42/coc-sh', {'do': 'yarn install --frozen-lockfile'} "Plug 'fannheyward/coc-texlab', {'do': 'yarn install --frozen-lockfile'} +"Plug 'dense-analysis/ale' call plug#end() " Setup AirLine @@ -542,6 +543,8 @@ function! s:show_documentation() endif endfunction +" Attempt to make pyright don't care about git root +autocmd FileType python let b:coc_root_patterns = ['.git', '.env'] " Highlight the symbol and its references when holding the cursor. autocmd CursorHold * silent call CocActionAsync('highlight') diff --git a/Common/zshrc b/Common/zshrc index b6830c6..1926db7 100644 --- a/Common/zshrc +++ b/Common/zshrc @@ -6,7 +6,7 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]] fi # If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH +export PATH=$HOME/bin:/usr/local/bin:$PATH # Check if env setup file exists if [ ! -f ~/.zsh_env_setup ]; then diff --git a/linux/tmux.conf b/linux/tmux.conf index 63b4cb3..4ea4670 100644 --- a/linux/tmux.conf +++ b/linux/tmux.conf @@ -4,6 +4,7 @@ set -g default-terminal "screen-256color" set -as terminal-overrides ",*:U8=0" set -s escape-time 10 # faster command sequences set -s focus-events on +set-option -sa terminal-overrides ',rxvt-256color:RGB' run-shell "powerline-daemon -q" #source "/usr/local/lib/python3.7/site-packages/powerline/bindings/tmux/powerline.conf" @@ -65,7 +66,7 @@ set -g bell-action any # Scroll in shell set -g terminal-overrides 'xterm*:smcup@:rmcup@' #set -wg xterm-keys 1 -set -g mouse on +set -g mouse on #set-option -s set-clipboard off # Sync panes -- cgit v1.2.3