From 4df7d9fce48df4bfff62a6aad20f22e73011b966 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 1 Nov 2022 21:47:18 +0300 Subject: [PATCH 01/76] zsh vi mode --- sub/zsh/options | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sub/zsh/options b/sub/zsh/options index 5c0783e..b684319 100644 --- a/sub/zsh/options +++ b/sub/zsh/options @@ -30,3 +30,5 @@ bindkey '^U' kill-whole-line bindkey -M vicmd '^U' kill-whole-line bindkey -M viins '^U' kill-whole-line bindkey -M viins '\e.' insert-last-word +bindkey -M vicmd '^K' up-line-or-history +bindkey -M vicmd '^J' down-line-or-history From 1aadffc0a64dae7acb1c93a7aead9161152a364f Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 1 Nov 2022 21:52:08 +0300 Subject: [PATCH 02/76] file mode --- functions/wifi | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 functions/wifi diff --git a/functions/wifi b/functions/wifi old mode 100644 new mode 100755 From 11f0258fc410d19f6ef2c5df21363fe4b7181058 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 6 Nov 2022 19:25:02 +0300 Subject: [PATCH 03/76] git config signingkey --- sub/git/gitconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/sub/git/gitconfig b/sub/git/gitconfig index ecfcda7..f29520d 100644 --- a/sub/git/gitconfig +++ b/sub/git/gitconfig @@ -56,3 +56,4 @@ [user] name = "TheK4n" email = "djvlad967891@gmail.com" + signingkey = "thek4n" From fadee362a6f237c3bc42821f50ee70e7b67e075d Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 6 Nov 2022 20:07:53 +0300 Subject: [PATCH 04/76] add etc files --- etc/sudoers | 5 +++++ etc/sudoers.d/custompower | 1 + etc/sudoers.d/wireguard | 1 + 3 files changed, 7 insertions(+) create mode 100644 etc/sudoers create mode 100644 etc/sudoers.d/custompower create mode 100644 etc/sudoers.d/wireguard diff --git a/etc/sudoers b/etc/sudoers new file mode 100644 index 0000000..7f1f035 --- /dev/null +++ b/etc/sudoers @@ -0,0 +1,5 @@ +%wheel ALL=(ALL:ALL) ALL + +@includedir /etc/sudoers.d + +Defaults passwd_timeout=0 diff --git a/etc/sudoers.d/custompower b/etc/sudoers.d/custompower new file mode 100644 index 0000000..eaea1b4 --- /dev/null +++ b/etc/sudoers.d/custompower @@ -0,0 +1 @@ +%custompower ALL= NOPASSWD: /sbin/reboot,/sbin/shutdown now,/sbin/systemctl suspend diff --git a/etc/sudoers.d/wireguard b/etc/sudoers.d/wireguard new file mode 100644 index 0000000..e60db73 --- /dev/null +++ b/etc/sudoers.d/wireguard @@ -0,0 +1 @@ +%wireguard ALL= NOPASSWD: /sbin/systemctl start wg-quick@wg0.service,/sbin/systemctl stop wg-quick@wg0.service From 27c0e8f7fc33f815f96c508b05e54a69d65451c8 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 6 Nov 2022 20:23:01 +0300 Subject: [PATCH 05/76] $VISUAL --- sub/bash/export | 1 + 1 file changed, 1 insertion(+) diff --git a/sub/bash/export b/sub/bash/export index dfba3d5..e7c63ab 100644 --- a/sub/bash/export +++ b/sub/bash/export @@ -2,6 +2,7 @@ umask 0077 export EDITOR="nvim" +export VISUAL="nvim" export PAGER="less -R" export HISTSIZE=10000 From cdbe7f6b73a9c9758dec2babd8167f8214e0ce44 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 7 Nov 2022 17:47:59 +0300 Subject: [PATCH 06/76] nvim plugins --- sub/vim/init.lua | 12 ++++++++++++ sub/vim/vimrc | 3 +++ 2 files changed, 15 insertions(+) diff --git a/sub/vim/init.lua b/sub/vim/init.lua index e8bc6ea..0883941 100644 --- a/sub/vim/init.lua +++ b/sub/vim/init.lua @@ -129,3 +129,15 @@ end require('telescope').load_extension('fzf') require("nvim-autopairs").setup {} + +require('gitsigns').setup() + +local null_ls = require("null-ls") + +null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua, + null_ls.builtins.diagnostics.eslint, + null_ls.builtins.completion.spell, + }, +}) diff --git a/sub/vim/vimrc b/sub/vim/vimrc index 4d1d308..9748c48 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -204,6 +204,9 @@ call vundle#begin() Plugin 'preservim/nerdtree' + Plugin 'lewis6991/gitsigns.nvim' + Plugin 'jose-elias-alvarez/null-ls.nvim' + call vundle#end() filetype plugin indent on From 59c5e8796d94e7c48b3188785d2117dcffee9900 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 7 Nov 2022 18:14:21 +0300 Subject: [PATCH 07/76] nvim plugins --- sub/vim/init.lua | 60 ++++++++++++++++++++++++++++-------------------- sub/vim/vimrc | 4 +--- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/sub/vim/init.lua b/sub/vim/init.lua index 0883941..69e1749 100644 --- a/sub/vim/init.lua +++ b/sub/vim/init.lua @@ -1,22 +1,41 @@ -local autosave = require("autosave") +local autosave = require("auto-save") autosave.setup( - { - enabled = true, - execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), - events = {"TextChanged", "InsertLeave"}, - conditions = { - exists = true, - filename_is_not = {}, - filetype_is_not = {}, - modifiable = true - }, - write_all_buffers = false, - on_off_commands = true, - clean_command_line_interval = 0, - debounce_delay = 0 - } +{ + enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it) + execution_message = { + message = function() -- message to print on save + return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S")) + end, + dim = 0.18, -- dim the color of `message` + cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea + }, + trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events + -- function that determines whether to save the current buffer or not + -- return true: if buffer is ok to be saved + -- return false: if it's not ok to be saved + condition = function(buf) + local fn = vim.fn + local utils = require("auto-save.utils.data") + + if + fn.getbufvar(buf, "&modifiable") == 1 and + utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then + return true -- met condition(s), can save + end + return false -- can't save + end, + write_all_buffers = false, -- write all buffers when the current one meets `condition` + debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds + callbacks = { -- functions to be executed at different intervals + enabling = nil, -- ran when enabling auto-save + disabling = nil, -- ran when disabling auto-save + before_asserting_save = nil, -- ran before checking `condition` + before_saving = nil, -- ran before doing the actual save + after_saving = nil -- ran after doing the actual save + } +} ) @@ -132,12 +151,3 @@ require("nvim-autopairs").setup {} require('gitsigns').setup() -local null_ls = require("null-ls") - -null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua, - null_ls.builtins.diagnostics.eslint, - null_ls.builtins.completion.spell, - }, -}) diff --git a/sub/vim/vimrc b/sub/vim/vimrc index 9748c48..96caa3f 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -181,7 +181,7 @@ call vundle#begin() Plugin 'preservim/vimux' Plugin 'rbgrouleff/bclose.vim' Plugin 'frazrepo/vim-rainbow' - Plugin 'Pocco81/AutoSave.nvim' + Plugin 'Pocco81/auto-save.nvim' " requiered patch your font Plugin 'ryanoasis/vim-devicons' Plugin 'windwp/nvim-autopairs' @@ -205,7 +205,6 @@ call vundle#begin() Plugin 'preservim/nerdtree' Plugin 'lewis6991/gitsigns.nvim' - Plugin 'jose-elias-alvarez/null-ls.nvim' call vundle#end() @@ -310,4 +309,3 @@ nnoremap l :call TabDo('call ToggleRelativeAbsoluteNumber()') < " Quick exiting without save nnoremap qq :qa! - From 93f606cbed7659a6aa240bb30830ce2d6adb3057 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 8 Nov 2022 19:56:30 +0300 Subject: [PATCH 08/76] gitconfig: pull.rebase --- sub/git/gitconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sub/git/gitconfig b/sub/git/gitconfig index f29520d..99860e6 100644 --- a/sub/git/gitconfig +++ b/sub/git/gitconfig @@ -10,6 +10,9 @@ [push] default = current +[pull] + rebase = false + [color] status = auto diff = auto From ce3d6a6ed493e64f94ad649b9dd9536285f960cc Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 16 Nov 2022 15:55:01 +0300 Subject: [PATCH 09/76] feat(functions/bluetooth): number of attemts if connect errors --- functions/bluetooth | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/functions/bluetooth b/functions/bluetooth index 449be4f..129039e 100755 --- a/functions/bluetooth +++ b/functions/bluetooth @@ -1,4 +1,16 @@ #!/bin/sh bssid="$(bluetoothctl devices | dmenu -p "Devices: " -l 20 | cut -d' ' -f2)" -bluetoothctl connect "$bssid" + +exit_counter=0 +until bluetoothctl connect "$bssid" +do + ((exit_counter+=1)) + + if [ "$exit_counter" -gt 3 ]; then + break + else + echo ... + sleep 1 + fi +done From 2ddc04cd3638c8c370303cad3d6ea9db325454f8 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sat, 19 Nov 2022 20:02:56 +0300 Subject: [PATCH 10/76] neovim: map ,qq to delete buffer, map ,qa to quit all --- sub/vim/vimrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sub/vim/vimrc b/sub/vim/vimrc index 96caa3f..2a70cfc 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -307,5 +307,6 @@ endfunction nnoremap l :call TabDo('call ToggleRelativeAbsoluteNumber()') +nnoremap qq :bd! " Quick exiting without save -nnoremap qq :qa! +nnoremap qa :qa! From 4b05b6c8ec551d02c0480198420144f0fa97ad1c Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sat, 19 Nov 2022 21:41:00 +0300 Subject: [PATCH 11/76] zsh vi mode, cursor style in normal and insert mode --- sub/zsh/options | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sub/zsh/options b/sub/zsh/options index b684319..5933bad 100644 --- a/sub/zsh/options +++ b/sub/zsh/options @@ -14,7 +14,36 @@ WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word PROMPT_EOL_MARK="" # configure key keybindings + +# Activate vim mode. bindkey -v + + +# Change cursor shape for different vi modes. +zle-keymap-select() { + if [[ ${KEYMAP} == vicmd ]] || + [[ $1 = 'block' ]]; then + echo -ne '\e[1 q' + + elif [[ ${KEYMAP} == main ]] || + [[ ${KEYMAP} == viins ]] || + [[ ${KEYMAP} = '' ]] || + [[ $1 = 'beam' ]]; then + echo -ne '\e[5 q' + fi +} + +zle -N zle-keymap-select + +# Use beam shape cursor on startup. +echo -ne '\e[5 q' + +# Use beam shape cursor for each new prompt. +preexec() { + echo -ne '\e[5 q' +} + + bindkey -M viins 'jk' vi-cmd-mode bindkey ' ' magic-space # do history expansion on space bindkey '^[[3;5~' kill-word # ctrl + Supr From 17ca9253316353b877836485315f8c54b7e92b3b Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 1 Dec 2022 22:21:44 +0300 Subject: [PATCH 12/76] func showtips --- sub/bash/functions | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sub/bash/functions b/sub/bash/functions index 2e1aa0b..a87fa00 100644 --- a/sub/bash/functions +++ b/sub/bash/functions @@ -258,3 +258,8 @@ rmt() { done } +# shows text from ~/.inittips +showtips() { + cat ~/.inittips 2>/dev/null +} + From 8dc512e8d4460f5d42ba210fe6114feabaf8813f Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 4 Dec 2022 21:12:46 +0300 Subject: [PATCH 13/76] fix typo .gitignore --- .gitignore | 2 +- sub/zsh/zshrc.d/00_test.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 sub/zsh/zshrc.d/00_test.sh diff --git a/.gitignore b/.gitignore index 4713cc9..852274b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ sub/zsh/plugins sub/bash/bashrc.d/* !sub/bash/bashrc.d/00_test.sh sub/zsh/zshrc.d/* -!sub/zsh/shrc.d/00_test.sh +!sub/zsh/zshrc.d/00_test.sh sub/vim/tmp/ diff --git a/sub/zsh/zshrc.d/00_test.sh b/sub/zsh/zshrc.d/00_test.sh new file mode 100644 index 0000000..729aa7f --- /dev/null +++ b/sub/zsh/zshrc.d/00_test.sh @@ -0,0 +1,2 @@ + +# Add here files to source it in ascending order like "01_hello.sh" From a49d001f4f287f6ed83df352529867c4482f2e32 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 8 Dec 2022 19:20:03 +0300 Subject: [PATCH 14/76] fix readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f46cd7..4682b43 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,8 @@ echo "Hello $USER!" | ,l | Line number styles | | ,c | Highlight cursor line | | ,/ | Toggle search highlight | -| ,`` | Close all without saving | +| ,qq | Delete current buffer +| ,qa | Close all without saving | | ,t | Tagbar | | ,rr | Run script in new tab (python, go, preview markdown)| | ,rm | Run script (make run) | From c58e1e7a55fa5126ffff63ad6298df80b3d5c493 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 8 Dec 2022 19:21:52 +0300 Subject: [PATCH 15/76] makefile --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 0ea8056..54b5a77 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ alacritty: ln -s $(PWD)/sub/alacritty/alacritty.yml ~/.config/alacritty/ vim: - echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; npm install -g pyright" + @echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; npm install -g pyright" echo "set editing-mode vi" >> ~/.inputrc test -d ~/.vim || \ ln -s $(PWD)/sub/vim ~/.vim @@ -57,7 +57,7 @@ git: ln -s $(PWD)/sub/git/hooks ~/.githooks ranger: - echo "sudo pacman -S highlight ttf-joypixels noto-fonts-emoji ueberzug poppler" + @echo "sudo pacman -S highlight ttf-joypixels noto-fonts-emoji ueberzug poppler" test -d ~/.config/ranger || \ mkdir -p ~/.config/ranger ln -s $(PWD)/sub/ranger/rc.conf ~/.config/ranger @@ -72,7 +72,7 @@ gpg: echo -e "default-cache-ttl 1\nmax-cache-ttl 1" > ~/.gnupg/gpg-agent.conf; echo RELOADAGENT | gpg-connect-agent i3: - echo "sudo pacman -S nitrogen picom compton ttf-font-awesome xdotool xclip maim" + @echo "sudo pacman -S nitrogen picom compton ttf-font-awesome xdotool xclip maim" test -d ~/.config/i3 || \ mkdir -p ~/.config/i3 mkdir -p ~/.config/i3status @@ -99,8 +99,8 @@ font: ./install.sh termux: - echo "apt install termux-api tsu" + @echo "apt install termux-api tsu" arch: - echo 'echo "ParallelDownloads = 5" >> /etc/pacman.conf' + @echo 'echo "ParallelDownloads = 5" >> /etc/pacman.conf' From 595c39e463a4d802a33dd54aa524031e7968fca0 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 11 Dec 2022 20:15:20 +0300 Subject: [PATCH 16/76] psql --- Makefile | 2 ++ sub/git/gitconfig | 1 + sub/psql/psqlrc | 4 ++++ 3 files changed, 7 insertions(+) create mode 100644 sub/psql/psqlrc diff --git a/Makefile b/Makefile index 54b5a77..83af856 100644 --- a/Makefile +++ b/Makefile @@ -104,3 +104,5 @@ termux: arch: @echo 'echo "ParallelDownloads = 5" >> /etc/pacman.conf' +psql: + ln -s $(PWD)/sub/psql/psqlrc ~/.psqlrc diff --git a/sub/git/gitconfig b/sub/git/gitconfig index 99860e6..d7a4696 100644 --- a/sub/git/gitconfig +++ b/sub/git/gitconfig @@ -43,6 +43,7 @@ find = "!f() { git log --pretty=format:\"%h %cd [%cn] %s%d\" --date=relative -S'pretty' -S\"$@\" | peco | awk '{print $1}' | xargs -I {} git diff {}^ {}; }; f" unstage = 'reset HEAD --' last = log -1 HEAD + branches = branch -avv --list diff --git a/sub/psql/psqlrc b/sub/psql/psqlrc new file mode 100644 index 0000000..20cd483 --- /dev/null +++ b/sub/psql/psqlrc @@ -0,0 +1,4 @@ +\set PROMPT1 '%n@%/%R%# %x' +\setenv LESS '-iMFXSx4R' +\setenv EDITOR 'nvim' +\x auto From 3cac0c1a9046a0ab78f8a48f56c7774799692ba6 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 29 Dec 2022 17:42:03 +0300 Subject: [PATCH 17/76] rm vim plugin: multicursor --- sub/vim/vimrc | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/sub/vim/vimrc b/sub/vim/vimrc index 2a70cfc..3b04a00 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -55,25 +55,6 @@ let g:netrw_winsize = 15 let g:netrw_keepdir = 0 - -" Mirror the NERDTree before showing it. This makes it the same on all tabs. -nnoremap nn :silent NERDTreeMirror:silent NERDTreeToggle - -" Toggle focus -nnoremap nf :wincmd p - -" Start NERDTree when Vim is started without file arguments. -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | wincmd p | endif - -" Exit Vim if NERDTree is the only window remaining in the only tab. -autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif - -" Close the tab if NERDTree is the only window remaining in it. -autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif - -let g:NERDTreeMapActivateNode='l' - set ttimeoutlen=0 "Понижаем задержку ввода escape последовательностей let &t_SI.="\e[5 q" "SI = режим вставки let &t_SR.="\e[3 q" "SR = режим замены @@ -138,6 +119,8 @@ set virtualedit=onemore " allow for cursor beyond last character " toggle hlsearch nnoremap / :set invhlsearch +cnoremap +cnoremap nnoremap nnoremap @@ -176,7 +159,6 @@ call vundle#begin() Plugin 'tpope/vim-surround' Plugin 'tpope/vim-commentary' Plugin 'ap/vim-css-color' - Plugin 'mg979/vim-visual-multi', {'branch': 'master'} Plugin 'preservim/tagbar' Plugin 'preservim/vimux' Plugin 'rbgrouleff/bclose.vim' @@ -202,7 +184,6 @@ call vundle#begin() Plugin 'nvim-telescope/telescope-fzf-native.nvim', {'do': 'make'} Plugin 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} - Plugin 'preservim/nerdtree' Plugin 'lewis6991/gitsigns.nvim' @@ -222,6 +203,8 @@ autocmd BufEnter * if (expand('%:t')=='manpage') | nnoremap rr autocmd BufEnter * if (&filetype=='python') | nnoremap rr :tabnew % :terminal python3 % :set nocursorline number norelativenumber G | endif autocmd BufEnter * if (&filetype=='go') | nnoremap rr :tabnew % :terminal go run % :set nocursorline number norelativenumber G | endif autocmd BufEnter * if (&filetype=='go') | nnoremap rf :!go fmt % | endif +autocmd BufEnter * if (&filetype=='rust') | nnoremap rr :tabnew % :terminal cargo run % :set nocursorline number norelativenumber G | endif +autocmd BufEnter * if (&filetype=='rust') | nnoremap rf :!cargo fmt % | endif autocmd BufEnter * if (&filetype=='markdown') | nnoremap rr :let g:buf_curline=line(".") :tabnew % :terminal glow % :set nocursorline number norelativenumber :exe buf_curline | endif autocmd BufEnter * if (&filetype=='vim') | nnoremap rr :so % @@ -252,20 +235,7 @@ colorscheme gruvbox set bg=dark -let g:multi_cursor_use_default_mapping=0 - -" Default mapping -let g:multi_cursor_start_word_key = '' -let g:multi_cursor_select_all_word_key = '' -let g:multi_cursor_start_key = 'g' -let g:multi_cursor_select_all_key = 'g' -let g:multi_cursor_next_key = '' -let g:multi_cursor_prev_key = '' -let g:multi_cursor_skip_key = '' -let g:multi_cursor_quit_key = '' - - -au FileType py,go,c,cpp,objc,js call rainbow#load() +au FileType py,go,c,cpp,objc,js,rs call rainbow#load() let g:rainbow_active = 1 From a4fecb61a44589ef5e0af38ed6ab7ba66d5a0443 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 8 Jan 2023 15:25:51 +0300 Subject: [PATCH 18/76] alias wake for termux --- sub/bash/aliases | 23 +++++++++++++---------- sub/vim/vimrc | 4 +++- sub/zsh/history | 1 + 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sub/bash/aliases b/sub/bash/aliases index 4cff489..a611347 100644 --- a/sub/bash/aliases +++ b/sub/bash/aliases @@ -76,10 +76,13 @@ alias shutdown='sudo /sbin/shutdown now' alias meminfo='free -mlth' alias psmem='ps auxf | sort -nr -k 4 | less -R' -alias wake='((speaker-test -t sine -f 400 &>/dev/null)& local pid=$! ;sleep 0.2s; kill -9 $pid) &>/dev/null' alias music='mplayer -shuffle ~/Music/*.mp3' - +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + alias wake='((speaker-test -t sine -f 400 &>/dev/null)& local pid=$! ;sleep 0.2s; kill -9 $pid) &>/dev/null' +elif [[ "$OSTYPE" == "linux-android"* ]]; then + alias wake='termux-notification --sound --vibrate 500,1000,200' +fi # python alias pipir='python3 -m pip install -r requirements.txt' @@ -105,16 +108,16 @@ alias drmi='docker image prune' # clipboard if [[ "$OSTYPE" == "linux-gnu"* ]]; then if [[ -n "$DISPLAY" ]]; then - alias ctc='xclip -selection clipboard -i' - alias ctv='xclip -selection clipboard -o' + alias copy='xclip -selection clipboard -i' + alias paste='xclip -selection clipboard -o' else - alias ctc='read -rd "EOF" TTYCLIPBOARD' - alias ctv='echo "$TTYCLIPBOARD"' + alias copy='read -rd "EOF" TTYCLIPBOARD' + alias paste='echo "$TTYCLIPBOARD"' fi elif [[ "$OSTYPE" == "linux-android"* ]]; then - alias ctc='termux-clipboard-set' - alias ctv='termux-clipboard-get' + alias copy='termux-clipboard-set' + alias paste='termux-clipboard-get' elif [[ "$OSTYPE" == "darwin" ]]; then - alias ctc='pbcopy' - alias ctv='pbpaste' + alias copy='pbcopy' + alias paste='pbpaste' fi diff --git a/sub/vim/vimrc b/sub/vim/vimrc index 3b04a00..e136565 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -85,7 +85,6 @@ set novisualbell set showcmd set showtabline=2 -set ignorecase set smartcase set incsearch @@ -280,3 +279,6 @@ nnoremap l :call TabDo('call ToggleRelativeAbsoluteNumber()') < nnoremap qq :bd! " Quick exiting without save nnoremap qa :qa! + +" expand %% to dirname of cur file in commandline +cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' diff --git a/sub/zsh/history b/sub/zsh/history index 7346767..2477f74 100644 --- a/sub/zsh/history +++ b/sub/zsh/history @@ -4,6 +4,7 @@ export HISTFILE=~/.zsh_history export HISTSIZE=1000 export SAVEHIST=2000 setopt HIST_IGNORE_SPACE +setopt HIST_FIND_NO_DUPS setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE setopt hist_ignore_dups # ignore duplicated commands history list setopt hist_ignore_space # ignore commands that start with space From b5d7b831c9d0c79c559d326e322a4558f1cac2b0 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 9 Jan 2023 20:58:09 +0300 Subject: [PATCH 19/76] fix terminal cursor --- sub/zsh/options | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sub/zsh/options b/sub/zsh/options index 5933bad..5f9f3a7 100644 --- a/sub/zsh/options +++ b/sub/zsh/options @@ -23,13 +23,14 @@ bindkey -v zle-keymap-select() { if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then - echo -ne '\e[1 q' + echo -ne '\e[2 q' elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || [[ ${KEYMAP} = '' ]] || [[ $1 = 'beam' ]]; then echo -ne '\e[5 q' + fi } @@ -38,11 +39,22 @@ zle -N zle-keymap-select # Use beam shape cursor on startup. echo -ne '\e[5 q' -# Use beam shape cursor for each new prompt. -preexec() { +_fix_cursor() { echo -ne '\e[5 q' } +precmd_functions+=(_fix_cursor) + +# Set cursor style (DECSCUSR), VT520. +# 0 -> blinking block. +# 1 -> blinking block (default). +# 2 -> steady block. +# 3 -> blinking underline. +# 4 -> steady underline. +# 5 -> blinking bar, xterm. +# 6 -> steady bar, xterm. + + bindkey -M viins 'jk' vi-cmd-mode bindkey ' ' magic-space # do history expansion on space From 5627bbb4201debf05a026b5258c672d3ad197697 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 9 Jan 2023 23:35:46 +0300 Subject: [PATCH 20/76] vim: alias Sw to save by root --- Makefile | 1 + functions/vim_askpass_helper | 2 ++ sub/vim/vimrc | 5 +++++ 3 files changed, 8 insertions(+) create mode 100755 functions/vim_askpass_helper diff --git a/Makefile b/Makefile index 83af856..779e0a9 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,7 @@ vim: ln -s $(PWD)/light/.vimrc ~/.vimrc mkdir -p ~/.config/nvim/lua ln -s ~/.vim/vimrc ~/.config/nvim/init.vim + ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin ln -s $(PWD)/sub/vim/init.lua ~/.config/nvim/lua/init.lua git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim nvim +PluginInstall +qall diff --git a/functions/vim_askpass_helper b/functions/vim_askpass_helper new file mode 100755 index 0000000..a530c4d --- /dev/null +++ b/functions/vim_askpass_helper @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +echo -e "OPTION title=vim\nOPTION default-prompt=[sudo] password for $USER:\nGETPIN" | pinentry-qt --display :0 2>/dev/null | grep ^D | cut -d" " -f2 diff --git a/sub/vim/vimrc b/sub/vim/vimrc index e136565..a241069 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -282,3 +282,8 @@ nnoremap qa :qa! " expand %% to dirname of cur file in commandline cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' + + + +# :Sw to save file by root +command Sw execute 'silent! write !SUDO_ASKPASS=$(which vim_askpass_helper) sudo -A tee % >/dev/null' From 41c1bae229d0fdca335a277f5c0e22d5d16f9025 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 10 Jan 2023 18:44:09 +0300 Subject: [PATCH 21/76] fix(vim): wrong commentary symbol --- functions/vim_askpass_helper | 2 +- sub/vim/vimrc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/vim_askpass_helper b/functions/vim_askpass_helper index a530c4d..d29648e 100755 --- a/functions/vim_askpass_helper +++ b/functions/vim_askpass_helper @@ -1,2 +1,2 @@ #!/usr/bin/env bash -echo -e "OPTION title=vim\nOPTION default-prompt=[sudo] password for $USER:\nGETPIN" | pinentry-qt --display :0 2>/dev/null | grep ^D | cut -d" " -f2 +echo -e "SETTITLE vim\nOPTION default-prompt=[sudo] password for $USER:\nGETPIN" | pinentry-qt --display :0 2>/dev/null | grep ^D | cut -d" " -f2 diff --git a/sub/vim/vimrc b/sub/vim/vimrc index a241069..1b1e126 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -285,5 +285,5 @@ cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' -# :Sw to save file by root +" :Sw to save file by root command Sw execute 'silent! write !SUDO_ASKPASS=$(which vim_askpass_helper) sudo -A tee % >/dev/null' From 04993a0e510d861737d2947b60b5b56b8f1f1b10 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 11 Jan 2023 18:46:07 +0300 Subject: [PATCH 22/76] fix(vim_askpass_helper): if passwords contains spaces it returns only first piece --- functions/vim_askpass_helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/vim_askpass_helper b/functions/vim_askpass_helper index d29648e..97d50eb 100755 --- a/functions/vim_askpass_helper +++ b/functions/vim_askpass_helper @@ -1,2 +1,2 @@ #!/usr/bin/env bash -echo -e "SETTITLE vim\nOPTION default-prompt=[sudo] password for $USER:\nGETPIN" | pinentry-qt --display :0 2>/dev/null | grep ^D | cut -d" " -f2 +echo -e "SETTITLE vim\nOPTION default-prompt=[sudo] password for $USER:\nGETPIN" | pinentry-qt --display :0 2>/dev/null | grep ^D | cut -d" " -f2- From a7669555a8bce9a6a980ea6e5cae7088cdfab5d0 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 15 Jan 2023 19:07:48 +0300 Subject: [PATCH 23/76] nvim ref to lua --- .gitignore | 2 + Makefile | 14 +-- sub/nvim/after/plugin/auto-save.lua | 40 +++++++ sub/nvim/after/plugin/cmp.lua | 51 +++++++++ sub/nvim/after/plugin/colorscheme.lua | 3 + sub/nvim/after/plugin/gitsigns.lua | 5 + sub/nvim/after/plugin/lspconfig.lua | 50 +++++++++ sub/nvim/after/plugin/lualine.lua | 5 + sub/nvim/after/plugin/luasnip.lua | 4 + sub/nvim/after/plugin/nvim-autopairs.lua | 5 + sub/nvim/after/plugin/nvim-treesitter.lua | 8 ++ sub/nvim/after/plugin/nvim-ts-autotag.lua | 6 ++ sub/nvim/after/plugin/rainbow.lua | 10 ++ sub/nvim/after/plugin/telescope.lua | 5 + sub/nvim/init.lua | 4 + sub/nvim/lua/base/base.lua | 85 +++++++++++++++ sub/nvim/lua/base/maps.lua | 125 ++++++++++++++++++++++ sub/nvim/lua/base/plugins.lua | 45 ++++++++ sub/nvim/lua/base/sourcer.lua | 5 + 19 files changed, 463 insertions(+), 9 deletions(-) create mode 100644 sub/nvim/after/plugin/auto-save.lua create mode 100644 sub/nvim/after/plugin/cmp.lua create mode 100644 sub/nvim/after/plugin/colorscheme.lua create mode 100644 sub/nvim/after/plugin/gitsigns.lua create mode 100644 sub/nvim/after/plugin/lspconfig.lua create mode 100644 sub/nvim/after/plugin/lualine.lua create mode 100644 sub/nvim/after/plugin/luasnip.lua create mode 100644 sub/nvim/after/plugin/nvim-autopairs.lua create mode 100644 sub/nvim/after/plugin/nvim-treesitter.lua create mode 100644 sub/nvim/after/plugin/nvim-ts-autotag.lua create mode 100644 sub/nvim/after/plugin/rainbow.lua create mode 100644 sub/nvim/after/plugin/telescope.lua create mode 100644 sub/nvim/init.lua create mode 100644 sub/nvim/lua/base/base.lua create mode 100644 sub/nvim/lua/base/maps.lua create mode 100644 sub/nvim/lua/base/plugins.lua create mode 100644 sub/nvim/lua/base/sourcer.lua diff --git a/.gitignore b/.gitignore index 852274b..fac7a65 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ sub/bash/bashrc.d/* sub/zsh/zshrc.d/* !sub/zsh/zshrc.d/00_test.sh sub/vim/tmp/ + +sub/nvim/plugin diff --git a/Makefile b/Makefile index 779e0a9..c14bbbf 100644 --- a/Makefile +++ b/Makefile @@ -36,18 +36,14 @@ alacritty: mkdir -p ~/.config/alacritty ln -s $(PWD)/sub/alacritty/alacritty.yml ~/.config/alacritty/ -vim: +nvim: @echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; npm install -g pyright" echo "set editing-mode vi" >> ~/.inputrc - test -d ~/.vim || \ - ln -s $(PWD)/sub/vim ~/.vim - ln -s $(PWD)/light/.vimrc ~/.vimrc - mkdir -p ~/.config/nvim/lua - ln -s ~/.vim/vimrc ~/.config/nvim/init.vim + test -d ~/.config/nvim || \ + ln -s $(PWD)/sub/nvim ~/.config/nvim ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin - ln -s $(PWD)/sub/vim/init.lua ~/.config/nvim/lua/init.lua - git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim - nvim +PluginInstall +qall + git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim + nvim +PackerCompile +PackerClean +PackerInstall +PackerUpdate +qall ssh: cat $(PWD)/sub/ssh/config >> ~/.ssh/config diff --git a/sub/nvim/after/plugin/auto-save.lua b/sub/nvim/after/plugin/auto-save.lua new file mode 100644 index 0000000..4c7c36f --- /dev/null +++ b/sub/nvim/after/plugin/auto-save.lua @@ -0,0 +1,40 @@ + +local status, autosave = pcall(require, "auto-save") +if (not status) then return end + +autosave.setup( +{ + enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it) + execution_message = { + message = function() -- message to print on save + return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S")) + end, + dim = 0.18, -- dim the color of `message` + cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea + }, + trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events + -- function that determines whether to save the current buffer or not + -- return true: if buffer is ok to be saved + -- return false: if it's not ok to be saved + condition = function(buf) + local fn = vim.fn + local utils = require("auto-save.utils.data") + + if + fn.getbufvar(buf, "&modifiable") == 1 and + utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then + return true -- met condition(s), can save + end + return false -- can't save + end, + write_all_buffers = false, -- write all buffers when the current one meets `condition` + debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds + callbacks = { -- functions to be executed at different intervals + enabling = nil, -- ran when enabling auto-save + disabling = nil, -- ran when disabling auto-save + before_asserting_save = nil, -- ran before checking `condition` + before_saving = nil, -- ran before doing the actual save + after_saving = nil -- ran after doing the actual save + } +} +) diff --git a/sub/nvim/after/plugin/cmp.lua b/sub/nvim/after/plugin/cmp.lua new file mode 100644 index 0000000..b09b7b6 --- /dev/null +++ b/sub/nvim/after/plugin/cmp.lua @@ -0,0 +1,51 @@ + +local status, cmp = pcall(require, "cmp") +if (not status) then return end + + +-- nvim-cmp setup +local cmp = require 'cmp' +cmp.setup { + completion = { + autocomplete = false + }, + 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' }, + }, +} diff --git a/sub/nvim/after/plugin/colorscheme.lua b/sub/nvim/after/plugin/colorscheme.lua new file mode 100644 index 0000000..10fccee --- /dev/null +++ b/sub/nvim/after/plugin/colorscheme.lua @@ -0,0 +1,3 @@ + + +vim.api.nvim_exec('colorscheme gruvbox', true) diff --git a/sub/nvim/after/plugin/gitsigns.lua b/sub/nvim/after/plugin/gitsigns.lua new file mode 100644 index 0000000..05777eb --- /dev/null +++ b/sub/nvim/after/plugin/gitsigns.lua @@ -0,0 +1,5 @@ + +local status, gitsigns = pcall(require, "gitsigns") +if (not status) then return end + +gitsigns.setup() diff --git a/sub/nvim/after/plugin/lspconfig.lua b/sub/nvim/after/plugin/lspconfig.lua new file mode 100644 index 0000000..baa7c33 --- /dev/null +++ b/sub/nvim/after/plugin/lspconfig.lua @@ -0,0 +1,50 @@ + +local status, nvim_lsp = pcall(require, "lspconfig") +if (not status) then return end + + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +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 + + -- Enable completion triggered by + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + + -- See `:help vim.lsp.*` for documentation on any of the below functions + 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) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) + +end + +-- Use a loop to conveniently call 'setup' on multiple servers and +-- map buffer local keybindings when the language server attaches +local servers = { 'pyright' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, + } + } +end diff --git a/sub/nvim/after/plugin/lualine.lua b/sub/nvim/after/plugin/lualine.lua new file mode 100644 index 0000000..f3ce4d6 --- /dev/null +++ b/sub/nvim/after/plugin/lualine.lua @@ -0,0 +1,5 @@ + +local status, lualine = pcall(require, "lualine") +if (not status) then return end + +lualine.setup() diff --git a/sub/nvim/after/plugin/luasnip.lua b/sub/nvim/after/plugin/luasnip.lua new file mode 100644 index 0000000..52761f1 --- /dev/null +++ b/sub/nvim/after/plugin/luasnip.lua @@ -0,0 +1,4 @@ + +local status, luasnip = pcall(require, "luasnip") +if (not status) then return end + diff --git a/sub/nvim/after/plugin/nvim-autopairs.lua b/sub/nvim/after/plugin/nvim-autopairs.lua new file mode 100644 index 0000000..d3c7655 --- /dev/null +++ b/sub/nvim/after/plugin/nvim-autopairs.lua @@ -0,0 +1,5 @@ + +local status, nvim_autopairs = pcall(require, "nvim_autopairs") +if (not status) then return end + +nvim_autopairs.setup() diff --git a/sub/nvim/after/plugin/nvim-treesitter.lua b/sub/nvim/after/plugin/nvim-treesitter.lua new file mode 100644 index 0000000..66e42f6 --- /dev/null +++ b/sub/nvim/after/plugin/nvim-treesitter.lua @@ -0,0 +1,8 @@ + +local status, nvim_treesitter = pcall(require, "nvim_treesitter") +if (not status) then return end + +nvim_treesitter.setup { + auto_install = true, +} + diff --git a/sub/nvim/after/plugin/nvim-ts-autotag.lua b/sub/nvim/after/plugin/nvim-ts-autotag.lua new file mode 100644 index 0000000..f9cb28d --- /dev/null +++ b/sub/nvim/after/plugin/nvim-ts-autotag.lua @@ -0,0 +1,6 @@ + +local status, nvim_ts_autotag = pcall(require, "nvim_ts_autotag") +if (not status) then return end + + +nvim_ts_autotag.setup() diff --git a/sub/nvim/after/plugin/rainbow.lua b/sub/nvim/after/plugin/rainbow.lua new file mode 100644 index 0000000..e7d2027 --- /dev/null +++ b/sub/nvim/after/plugin/rainbow.lua @@ -0,0 +1,10 @@ + +vim.api.nvim_exec([[ + let g:rainbow_active = 1 +]], true) + +vim.api.nvim_create_autocmd('FileType', + { + pattern = {"*"}, + command = 'RainbowToggle' + }) diff --git a/sub/nvim/after/plugin/telescope.lua b/sub/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..a5cf702 --- /dev/null +++ b/sub/nvim/after/plugin/telescope.lua @@ -0,0 +1,5 @@ + +local status, telescope = pcall(require, "telescope") +if (not status) then return end + +telescope.load_extension('fzf') diff --git a/sub/nvim/init.lua b/sub/nvim/init.lua new file mode 100644 index 0000000..560a6b6 --- /dev/null +++ b/sub/nvim/init.lua @@ -0,0 +1,4 @@ + +require("base.sourcer") + + diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/base.lua new file mode 100644 index 0000000..e4a9d75 --- /dev/null +++ b/sub/nvim/lua/base/base.lua @@ -0,0 +1,85 @@ + +vim.opt.ruler = true + + +vim.scriptencoding = 'utf-8' +vim.opt.encoding = 'utf-8' +vim.opt.fileencoding = 'utf-8' + +vim.opt.clipboard = 'unnamedplus' +vim.opt.shell = 'bash' + +vim.opt.ttimeoutlen = 0 + +-- vim.opt.compatible = false + +vim.opt.expandtab = true +vim.opt.smarttab = true +vim.opt.tabstop = 4 + + +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.autoindent = true +vim.opt.smartindent = true +vim.opt.wrap = false + +vim.opt.ttyfast = true +vim.opt.autoread = true + + +vim.opt.errorbells = false +vim.opt.visualbell = false +vim.opt.showcmd = true +vim.opt.showtabline = 2 + +vim.opt.smartcase = true +vim.opt.incsearch = true + +vim.opt.mousehide = true +vim.opt.mouse = 'a' + +vim.opt.colorcolumn = '81' +vim.opt.scrolloff = 7 + +vim.opt.backup = true +vim.opt.swapfile = false +vim.opt.undofile = true +vim.opt.history = 1000 +vim.opt.undoreload = 1000 +vim.opt.backupdir = '~/.vim/tmp/backup/' +vim.opt.undodir = '~/.vim/tmp/undo/' +vim.opt.directory = '~/.vim/tmp/swap/' + +vim.api.nvim_exec([[ +function! MakeDirIfNoExists(path) + if !isdirectory(expand(a:path)) + call mkdir(expand(a:path), "p") + endif +endfunction + + +" make this dirs if no exists previously +silent! call MakeDirIfNoExists(&undodir) +silent! call MakeDirIfNoExists(&backupdir) +silent! call MakeDirIfNoExists(&directory) +]], true) + +vim.opt.ffs = 'unix,mac' + +vim.opt.path:append { '**' } -- Finding files - Search down into subfolders + +vim.opt.cursorline = true + + + +vim.cmd([[let &t_SI.="\e[5 q"]]) +vim.cmd([[let &t_SR.="\e[3 q"]]) +vim.cmd([[let &t_EI.="\e[1 q"]]) + + +vim.cmd([[let g:netrw_banner = 0]]) -- hide banner +vim.cmd([[let g:netrw_liststyle = 3]]) -- tree instead of plain view +vim.cmd([[let g:netrw_browse_split = 0]]) +vim.cmd([[let g:netrw_winsize = 15]]) +vim.cmd([[let g:netrw_keepdir = 0]]) diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua new file mode 100644 index 0000000..c0c3feb --- /dev/null +++ b/sub/nvim/lua/base/maps.lua @@ -0,0 +1,125 @@ +local keymap = vim.keymap + + +vim.g.mapleader = ',' + + +vim.api.nvim_exec([[ + " like tabdo but restore the current tab + function! TabDo(command) + let currTab=tabpagenr() + execute 'tabdo ' . a:command + execute 'tabn ' . currTab + endfunction + + " like bufdo but restore the current buffer + function! BufDo(command) + let currBuff=bufnr("%") + execute 'bufdo ' . a:command + execute 'buffer ' . currBuff + endfunction + + " like windo but restore the current window + function! WinDo(command) + let currwin=winnr() + execute 'windo ' . a:command + execute currwin . 'wincmd w' + endfunction +]], true) + +keymap.set('n', 'c', [[:call TabDo('set cursorline!')]], {silent = true}) + +keymap.set('n', '/', [[:set invhlsearch]], {silent = true}) + +keymap.set('i', 'jk', '') +keymap.set('i', 'ол', '') + + + +-- x to blackhole +keymap.set('n', 'x', '"_x') + +-- Increment/decrement +keymap.set('n', '+', '') +keymap.set('n', '-', '') + +-- Select all +keymap.set('n', '', 'ggG') + + +-- Scroll tabs +keymap.set("n", '', ':tabnext') +keymap.set("n", '', ':tabprev') + + +-- Kill current buffer +keymap.set("n", 'qq', ':bd!') +-- Quick exit without saving +keymap.set("n", 'qa', ':qa!') + + +keymap.set("n", 'eh', ':set list!') +vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]] + + +-- Tags panes (ctags required) +keymap.set("n", 't', ':TagbarToggle') + + +-- Telescope +keymap.set("n", 'ff', 'Telescope find_files') +keymap.set("n", 'fg', 'Telescope live_grep') + + +-- Expand %% to dirname of current file in command line +keymap.set("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true}) + + +-- Save from root +vim.api.nvim_create_user_command('Sw', [[execute 'silent! write !SUDO_ASKPASS=$(which vim_askpass_helper) sudo -A tee % >/dev/null']], {}) + + + +function create_autocmd_filetype(func) + create_autocmd = vim.api.nvim_create_autocmd + + create_autocmd("BufEnter", + { pattern = '*', callback = func} + ) +end + +function set_keymap_run_script() + if vim.bo.filetype == 'python' then + cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], 'python3') + keymap.set("n", "rr", cmd_string) + end +end + +create_autocmd_filetype(set_keymap_run_script) + + + + +-- Toggle line number style +vim.opt.number = true +vim.opt.relativenumber = true + +vim.api.nvim_exec([[ +function! ToggleRelativeAbsoluteNumber() + if !&number && !&relativenumber + set number + set norelativenumber + elseif &number && !&relativenumber + set nonumber + set relativenumber + elseif !&number && &relativenumber + set number + set relativenumber + elseif &number && &relativenumber + set nonumber + set norelativenumber + endif +endfunction +]], true) + +keymap.set('n', 'l', [[:call TabDo('call ToggleRelativeAbsoluteNumber()') ]], {silent = true}) diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua new file mode 100644 index 0000000..4948373 --- /dev/null +++ b/sub/nvim/lua/base/plugins.lua @@ -0,0 +1,45 @@ +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + use 'VundleVim/Vundle.vim' + + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true } + } + + use 'morhetz/gruvbox' + use 'tpope/vim-surround' + use 'tpope/vim-commentary' + use 'ap/vim-css-color' + use 'preservim/tagbar' + use 'preservim/vimux' + use 'rbgrouleff/bclose.vim' + use 'frazrepo/vim-rainbow' + + -- requiered patch your font + use 'ryanoasis/vim-devicons' + use 'powerman/vim-plugin-ruscmd' -- Russian navigation + + use 'Pocco81/auto-save.nvim' + use 'windwp/nvim-autopairs' + + -- pyright + use 'neovim/nvim-lspconfig' + use 'hrsh7th/nvim-cmp' + use 'hrsh7th/cmp-nvim-lsp' + use 'saadparwaiz1/cmp_luasnip' + use 'L3MON4D3/LuaSnip' + use 'nvim-lua/plenary.nvim' + + use { + 'nvim-telescope/telescope.nvim', + requires = { 'nvim-telescope/telescope-fzf-native.nvim', run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', opt = false } + } + use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } + + use 'lewis6991/gitsigns.nvim' + use 'windwp/nvim-ts-autotag' + +end) diff --git a/sub/nvim/lua/base/sourcer.lua b/sub/nvim/lua/base/sourcer.lua new file mode 100644 index 0000000..bf1b36b --- /dev/null +++ b/sub/nvim/lua/base/sourcer.lua @@ -0,0 +1,5 @@ + +require("base.base") +require("base.maps") +require("base.plugins") + From 94e7f2828259325e78556c42d9aed9a6fa02471a Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 15 Jan 2023 19:57:52 +0300 Subject: [PATCH 24/76] fix(nvim): fix rainbow plugin --- .gitignore | 1 + Makefile | 2 +- sub/nvim/after/plugin/colorscheme.lua | 2 ++ sub/nvim/after/plugin/rainbow.lua | 11 +++++++---- sub/nvim/lua/base/base.lua | 28 ++++++++++++++------------- sub/nvim/lua/base/plugins.lua | 4 ++-- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index fac7a65..408ac6d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ sub/zsh/zshrc.d/* sub/vim/tmp/ sub/nvim/plugin +sub/nvim/tmp/ diff --git a/Makefile b/Makefile index c14bbbf..eca5564 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ nvim: ln -s $(PWD)/sub/nvim ~/.config/nvim ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim - nvim +PackerCompile +PackerClean +PackerInstall +PackerUpdate +qall + nvim +PackerCompile +PackerClean +PackerInstall +PackerUpdate +PackerUpdate +qall ssh: cat $(PWD)/sub/ssh/config >> ~/.ssh/config diff --git a/sub/nvim/after/plugin/colorscheme.lua b/sub/nvim/after/plugin/colorscheme.lua index 10fccee..4b64ef0 100644 --- a/sub/nvim/after/plugin/colorscheme.lua +++ b/sub/nvim/after/plugin/colorscheme.lua @@ -1,3 +1,5 @@ +local status, autosave = pcall(require, "gruvbox") +if (not status) then return end vim.api.nvim_exec('colorscheme gruvbox', true) diff --git a/sub/nvim/after/plugin/rainbow.lua b/sub/nvim/after/plugin/rainbow.lua index e7d2027..0994efc 100644 --- a/sub/nvim/after/plugin/rainbow.lua +++ b/sub/nvim/after/plugin/rainbow.lua @@ -1,10 +1,13 @@ +if (packer_plugins["vim-rainbow"] and packer_plugins["vim-rainbow"].loaded) then + return +end vim.api.nvim_exec([[ let g:rainbow_active = 1 ]], true) vim.api.nvim_create_autocmd('FileType', - { - pattern = {"*"}, - command = 'RainbowToggle' - }) + { + pattern = {"*"}, + command = 'RainbowToggle' + }) diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/base.lua index e4a9d75..1a682af 100644 --- a/sub/nvim/lua/base/base.lua +++ b/sub/nvim/lua/base/base.lua @@ -47,22 +47,24 @@ vim.opt.swapfile = false vim.opt.undofile = true vim.opt.history = 1000 vim.opt.undoreload = 1000 -vim.opt.backupdir = '~/.vim/tmp/backup/' -vim.opt.undodir = '~/.vim/tmp/undo/' -vim.opt.directory = '~/.vim/tmp/swap/' + +local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand("~/.config") + +vim.opt.undodir = { prefix .. "/nvim/tmp/.undo//"} +vim.opt.backupdir = {prefix .. "/nvim/tmp/.backup//"} +vim.opt.directory = { prefix .. "/nvim/tmp/.swp//"} vim.api.nvim_exec([[ -function! MakeDirIfNoExists(path) - if !isdirectory(expand(a:path)) - call mkdir(expand(a:path), "p") - endif -endfunction + function! MakeDirIfNoExists(path) + if !isdirectory(expand(a:path)) + call mkdir(expand(a:path), "p") + endif + endfunction - -" make this dirs if no exists previously -silent! call MakeDirIfNoExists(&undodir) -silent! call MakeDirIfNoExists(&backupdir) -silent! call MakeDirIfNoExists(&directory) + " make this dirs if no exists previously + silent! call MakeDirIfNoExists(&undodir) + silent! call MakeDirIfNoExists(&backupdir) + silent! call MakeDirIfNoExists(&directory) ]], true) vim.opt.ffs = 'unix,mac' diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 4948373..033394f 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -9,7 +9,7 @@ return require('packer').startup(function(use) requires = { 'kyazdani42/nvim-web-devicons', opt = true } } - use 'morhetz/gruvbox' + use 'ellisonleao/gruvbox.nvim' use 'tpope/vim-surround' use 'tpope/vim-commentary' use 'ap/vim-css-color' @@ -35,7 +35,7 @@ return require('packer').startup(function(use) use { 'nvim-telescope/telescope.nvim', - requires = { 'nvim-telescope/telescope-fzf-native.nvim', run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', opt = false } + requires = { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = false } } use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } From c643e6fc2898561b45c0e0ea70aabaeb38fc1c08 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 15 Jan 2023 20:24:02 +0300 Subject: [PATCH 25/76] add(nvim) silent all maps, map ,rr to run scripts --- sub/nvim/lua/base/maps.lua | 46 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua index c0c3feb..2aa314a 100644 --- a/sub/nvim/lua/base/maps.lua +++ b/sub/nvim/lua/base/maps.lua @@ -31,48 +31,48 @@ keymap.set('n', 'c', [[:call TabDo('set cursorline!')]], {silent = t keymap.set('n', '/', [[:set invhlsearch]], {silent = true}) -keymap.set('i', 'jk', '') -keymap.set('i', 'ол', '') +keymap.set('i', 'jk', '', {silent = true}) +keymap.set('i', 'ол', '', {silent = true}) -- x to blackhole -keymap.set('n', 'x', '"_x') +keymap.set('n', 'x', '"_x', {silent = true}) -- Increment/decrement -keymap.set('n', '+', '') -keymap.set('n', '-', '') +keymap.set('n', '+', '', {silent = true}) +keymap.set('n', '-', '', {silent = true}) -- Select all -keymap.set('n', '', 'ggG') +keymap.set('n', '', 'ggG', {silent = true}) -- Scroll tabs -keymap.set("n", '', ':tabnext') -keymap.set("n", '', ':tabprev') +keymap.set("n", '', ':tabnext', {silent = true}) +keymap.set("n", '', ':tabprev', {silent = true}) -- Kill current buffer -keymap.set("n", 'qq', ':bd!') +keymap.set("n", 'qq', ':bd!', {silent = true}) -- Quick exit without saving -keymap.set("n", 'qa', ':qa!') +keymap.set("n", 'qa', ':qa!', {silent = true}) -keymap.set("n", 'eh', ':set list!') +keymap.set("n", 'eh', ':set list!', {silent = true}) vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]] --- Tags panes (ctags required) -keymap.set("n", 't', ':TagbarToggle') +-- Tags panel (ctags required) +keymap.set("n", 't', ':TagbarToggle', {silent = true}) -- Telescope -keymap.set("n", 'ff', 'Telescope find_files') -keymap.set("n", 'fg', 'Telescope live_grep') +keymap.set("n", 'ff', 'Telescope find_files', {silent = true}) +keymap.set("n", 'fg', 'Telescope live_grep', {silent = true}) -- Expand %% to dirname of current file in command line -keymap.set("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true}) +keymap.set("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true, silent = true}) -- Save from root @@ -88,14 +88,18 @@ function create_autocmd_filetype(func) ) end -function set_keymap_run_script() - if vim.bo.filetype == 'python' then - cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], 'python3') - keymap.set("n", "rr", cmd_string) +function create_func(ft, cmd) + return function() + if vim.bo.filetype == ft then + cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) + keymap.set("n", "rr", cmd_string) + end end end -create_autocmd_filetype(set_keymap_run_script) +create_autocmd_filetype(create_func('python', 'python3')) +create_autocmd_filetype(create_func('go', 'go run')) +create_autocmd_filetype(create_func('rust', 'cargo run')) From 68e0356db991200401d5e8f9122f6dac3aae9b02 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 15 Jan 2023 20:29:31 +0300 Subject: [PATCH 26/76] fix(nvim) wrong plugin names --- sub/nvim/after/plugin/nvim-autopairs.lua | 2 +- sub/nvim/after/plugin/nvim-treesitter.lua | 2 +- sub/nvim/after/plugin/nvim-ts-autotag.lua | 2 +- sub/nvim/lua/base/maps.lua | 2 +- sub/nvim/lua/base/plugins.lua | 2 -- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sub/nvim/after/plugin/nvim-autopairs.lua b/sub/nvim/after/plugin/nvim-autopairs.lua index d3c7655..1af017c 100644 --- a/sub/nvim/after/plugin/nvim-autopairs.lua +++ b/sub/nvim/after/plugin/nvim-autopairs.lua @@ -1,5 +1,5 @@ -local status, nvim_autopairs = pcall(require, "nvim_autopairs") +local status, nvim_autopairs = pcall(require, "nvim-autopairs") if (not status) then return end nvim_autopairs.setup() diff --git a/sub/nvim/after/plugin/nvim-treesitter.lua b/sub/nvim/after/plugin/nvim-treesitter.lua index 66e42f6..4f5eb9c 100644 --- a/sub/nvim/after/plugin/nvim-treesitter.lua +++ b/sub/nvim/after/plugin/nvim-treesitter.lua @@ -1,5 +1,5 @@ -local status, nvim_treesitter = pcall(require, "nvim_treesitter") +local status, nvim_treesitter = pcall(require, "nvim-treesitter") if (not status) then return end nvim_treesitter.setup { diff --git a/sub/nvim/after/plugin/nvim-ts-autotag.lua b/sub/nvim/after/plugin/nvim-ts-autotag.lua index f9cb28d..0daef25 100644 --- a/sub/nvim/after/plugin/nvim-ts-autotag.lua +++ b/sub/nvim/after/plugin/nvim-ts-autotag.lua @@ -1,5 +1,5 @@ -local status, nvim_ts_autotag = pcall(require, "nvim_ts_autotag") +local status, nvim_ts_autotag = pcall(require, "nvim-ts-autotag") if (not status) then return end diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua index 2aa314a..dc72dd2 100644 --- a/sub/nvim/lua/base/maps.lua +++ b/sub/nvim/lua/base/maps.lua @@ -72,7 +72,7 @@ keymap.set("n", 'fg', 'Telescope live_grep', {silent = true}) -- Expand %% to dirname of current file in command line -keymap.set("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true, silent = true}) +keymap.set("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true}) -- Save from root diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 033394f..3572108 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -2,8 +2,6 @@ return require('packer').startup(function(use) -- Packer can manage itself use 'wbthomason/packer.nvim' - use 'VundleVim/Vundle.vim' - use { 'nvim-lualine/lualine.nvim', requires = { 'kyazdani42/nvim-web-devicons', opt = true } From 92b407a376f7996aa266ebfbc1a2a9960eaa9caa Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 15 Jan 2023 21:10:36 +0300 Subject: [PATCH 27/76] add(nvim) clipboard --- sub/nvim/lua/base/base.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/base.lua index 1a682af..ddb451c 100644 --- a/sub/nvim/lua/base/base.lua +++ b/sub/nvim/lua/base/base.lua @@ -6,7 +6,7 @@ vim.scriptencoding = 'utf-8' vim.opt.encoding = 'utf-8' vim.opt.fileencoding = 'utf-8' -vim.opt.clipboard = 'unnamedplus' +vim.opt.clipboard:append { 'unnamedplus' } vim.opt.shell = 'bash' vim.opt.ttimeoutlen = 0 @@ -42,6 +42,10 @@ vim.opt.mouse = 'a' vim.opt.colorcolumn = '81' vim.opt.scrolloff = 7 + +vim.opt.termguicolors = true +vim.opt.background = 'dark' + vim.opt.backup = true vim.opt.swapfile = false vim.opt.undofile = true From f7765bedaaef1e29cef98674a60007c27292565b Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 15 Jan 2023 21:28:48 +0300 Subject: [PATCH 28/76] nvim: silent to ,rr command --- sub/nvim/lua/base/maps.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua index dc72dd2..eedeeff 100644 --- a/sub/nvim/lua/base/maps.lua +++ b/sub/nvim/lua/base/maps.lua @@ -92,7 +92,7 @@ function create_func(ft, cmd) return function() if vim.bo.filetype == ft then cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) - keymap.set("n", "rr", cmd_string) + keymap.set("n", "rr", cmd_string, {silent = true}) end end end From 8c157fc97a784961aa95b0606054515703c141f7 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 15 Jan 2023 22:31:42 +0300 Subject: [PATCH 29/76] add(zsh) suffix aliases --- sub/nvim/lua/base/base.lua | 9 +++++++++ sub/nvim/lua/base/maps.lua | 5 +++++ sub/zsh/aliases | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/base.lua index ddb451c..320a17d 100644 --- a/sub/nvim/lua/base/base.lua +++ b/sub/nvim/lua/base/base.lua @@ -89,3 +89,12 @@ vim.cmd([[let g:netrw_liststyle = 3]]) -- tree instead of plain view vim.cmd([[let g:netrw_browse_split = 0]]) vim.cmd([[let g:netrw_winsize = 15]]) vim.cmd([[let g:netrw_keepdir = 0]]) + + +-- Highlight yanked text for a while +vim.api.nvim_create_autocmd("TextYankPost", { + pattern = "*", + callback = function() + vim.highlight.on_yank() + end, +}) diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua index eedeeff..9727c82 100644 --- a/sub/nvim/lua/base/maps.lua +++ b/sub/nvim/lua/base/maps.lua @@ -43,6 +43,10 @@ keymap.set('n', 'x', '"_x', {silent = true}) keymap.set('n', '+', '', {silent = true}) keymap.set('n', '-', '', {silent = true}) +-- map \ to prev finding +keymap.set('n', [[\]], ',', {silent = true}) +keymap.set('v', [[\]], ',', {silent = true}) + -- Select all keymap.set('n', '', 'ggG', {silent = true}) @@ -126,4 +130,5 @@ function! ToggleRelativeAbsoluteNumber() endfunction ]], true) +-- Toggle line number style keymap.set('n', 'l', [[:call TabDo('call ToggleRelativeAbsoluteNumber()') ]], {silent = true}) diff --git a/sub/zsh/aliases b/sub/zsh/aliases index 6a2543b..a05774a 100644 --- a/sub/zsh/aliases +++ b/sub/zsh/aliases @@ -5,4 +5,9 @@ alias -g OUT="1>/dev/null" # stdOUT alias -g ERR="2>/dev/null" # stdERR alias -g ALL="1>/dev/null 2>&1" alias -g BG="&>/dev/null &" + +alias -s mp4='vlc' +alias -s mp3='audacious' +alias -s flac='audacious' + bindkey '`' autosuggest-accept From d5a125567ecece95a1571a29ec2f07ea53d06e42 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 16 Jan 2023 01:15:45 +0300 Subject: [PATCH 30/76] asd --- sub/nvim/lua/base/base.lua | 4 +- sub/vim/init.lua | 153 ------------------------------------- sub/vim/vimrc | 17 ----- 3 files changed, 3 insertions(+), 171 deletions(-) delete mode 100644 sub/vim/init.lua diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/base.lua index 320a17d..b919d3d 100644 --- a/sub/nvim/lua/base/base.lua +++ b/sub/nvim/lua/base/base.lua @@ -11,7 +11,9 @@ vim.opt.shell = 'bash' vim.opt.ttimeoutlen = 0 --- vim.opt.compatible = false +vim.opt.compatible = false + +vim.opt.hidden = true vim.opt.expandtab = true vim.opt.smarttab = true diff --git a/sub/vim/init.lua b/sub/vim/init.lua deleted file mode 100644 index 69e1749..0000000 --- a/sub/vim/init.lua +++ /dev/null @@ -1,153 +0,0 @@ - -local autosave = require("auto-save") - -autosave.setup( -{ - enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it) - execution_message = { - message = function() -- message to print on save - return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S")) - end, - dim = 0.18, -- dim the color of `message` - cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea - }, - trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events - -- function that determines whether to save the current buffer or not - -- return true: if buffer is ok to be saved - -- return false: if it's not ok to be saved - condition = function(buf) - local fn = vim.fn - local utils = require("auto-save.utils.data") - - if - fn.getbufvar(buf, "&modifiable") == 1 and - utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then - return true -- met condition(s), can save - end - return false -- can't save - end, - write_all_buffers = false, -- write all buffers when the current one meets `condition` - debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds - callbacks = { -- functions to be executed at different intervals - enabling = nil, -- ran when enabling auto-save - disabling = nil, -- ran when disabling auto-save - before_asserting_save = nil, -- ran before checking `condition` - before_saving = nil, -- ran before doing the actual save - after_saving = nil -- ran after doing the actual save - } -} -) - - - --- Set completeopt to have a better completion experience -vim.o.completeopt = 'menuone,noselect' - --- luasnip setup -local luasnip = require 'luasnip' - --- nvim-cmp setup -local cmp = require 'cmp' -cmp.setup { - completion = { - autocomplete = false - }, - 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' }, - }, -} - - - - -local nvim_lsp = require('lspconfig') - --- Use an on_attach function to only map the following keys --- after the language server attaches to the current buffer -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 - - -- Enable completion triggered by - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - local opts = { noremap=true, silent=true } - - -- See `:help vim.lsp.*` for documentation on any of the below functions - 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) - buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) - -end - --- Use a loop to conveniently call 'setup' on multiple servers and --- map buffer local keybindings when the language server attaches -local servers = { 'pyright' } -for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - on_attach = on_attach, - flags = { - debounce_text_changes = 150, - } - } -end - - -require('telescope').load_extension('fzf') - -require("nvim-autopairs").setup {} - -require('gitsigns').setup() - diff --git a/sub/vim/vimrc b/sub/vim/vimrc index 1b1e126..0361b00 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -167,25 +167,8 @@ call vundle#begin() Plugin 'ryanoasis/vim-devicons' Plugin 'windwp/nvim-autopairs' - " pyright - Plugin 'neovim/nvim-lspconfig' - Plugin 'hrsh7th/nvim-cmp' - Plugin 'hrsh7th/cmp-nvim-lsp' - Plugin 'saadparwaiz1/cmp_luasnip' - Plugin 'L3MON4D3/LuaSnip' - Plugin 'nvim-lua/plenary.nvim' - Plugin 'powerman/vim-plugin-ruscmd' " Russian navigation - " golang - " Plugin 'fatih/vim-go' - Plugin 'nvim-telescope/telescope.nvim' - Plugin 'nvim-telescope/telescope-fzf-native.nvim', {'do': 'make'} - Plugin 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} - - - Plugin 'lewis6991/gitsigns.nvim' - call vundle#end() filetype plugin indent on From 60bcfd24b5d311055364b25d39bfe19c16aa8099 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 16 Jan 2023 19:41:00 +0300 Subject: [PATCH 31/76] ref(nvim): vimscript func to lua --- Makefile | 2 -- sub/nvim/lua/base/base.lua | 32 ++++++++++++++++---------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index eca5564..4a0f409 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,6 @@ alacritty: nvim: @echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; npm install -g pyright" - echo "set editing-mode vi" >> ~/.inputrc - test -d ~/.config/nvim || \ ln -s $(PWD)/sub/nvim ~/.config/nvim ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/base.lua index b919d3d..1e2ff3e 100644 --- a/sub/nvim/lua/base/base.lua +++ b/sub/nvim/lua/base/base.lua @@ -35,7 +35,7 @@ vim.opt.visualbell = false vim.opt.showcmd = true vim.opt.showtabline = 2 -vim.opt.smartcase = true +vim.opt.smartcase = true -- if search line hasn`t Upper case chars - ignore case search, else case-sensivity search vim.opt.incsearch = true vim.opt.mousehide = true @@ -54,24 +54,24 @@ vim.opt.undofile = true vim.opt.history = 1000 vim.opt.undoreload = 1000 -local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand("~/.config") +local prefix = vim.fn.expand("~/.cache/nvim/tmp") -vim.opt.undodir = { prefix .. "/nvim/tmp/.undo//"} -vim.opt.backupdir = {prefix .. "/nvim/tmp/.backup//"} -vim.opt.directory = { prefix .. "/nvim/tmp/.swp//"} +vim.opt.undodir = { prefix .. "/undo//" } +vim.opt.backupdir = { prefix .. "/backup//" } +vim.opt.directory = { prefix .. "/swp//" } -vim.api.nvim_exec([[ - function! MakeDirIfNoExists(path) - if !isdirectory(expand(a:path)) - call mkdir(expand(a:path), "p") - endif - endfunction - " make this dirs if no exists previously - silent! call MakeDirIfNoExists(&undodir) - silent! call MakeDirIfNoExists(&backupdir) - silent! call MakeDirIfNoExists(&directory) -]], true) +function makeDirIfNoExists(path) + local path = path["_value"] + if (vim.fn.isdirectory(path) == 0) then + vim.fn.mkdir(path, "p") + end +end + +-- make this dirs if no exists previously +makeDirIfNoExists(vim.opt.undodir) +makeDirIfNoExists(vim.opt.backupdir) +makeDirIfNoExists(vim.opt.directory) vim.opt.ffs = 'unix,mac' From 7dda7ec2a0b95dbe418e3bc1354fbe4ed5362ce2 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 16 Jan 2023 21:41:08 +0300 Subject: [PATCH 32/76] ref(nvim): vimscript func to lua --- sub/nvim/lua/base/maps.lua | 98 ++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua index 9727c82..7f4f527 100644 --- a/sub/nvim/lua/base/maps.lua +++ b/sub/nvim/lua/base/maps.lua @@ -4,30 +4,15 @@ local keymap = vim.keymap vim.g.mapleader = ',' -vim.api.nvim_exec([[ - " like tabdo but restore the current tab - function! TabDo(command) - let currTab=tabpagenr() - execute 'tabdo ' . a:command - execute 'tabn ' . currTab - endfunction +function create_function_tabdo(command) + return function() + local currTab = vim.fn.tabpagenr() + vim.cmd(string.format([[tabdo %s]], command)) + vim.cmd(string.format([[tabn %s]], currTab)) + end +end - " like bufdo but restore the current buffer - function! BufDo(command) - let currBuff=bufnr("%") - execute 'bufdo ' . a:command - execute 'buffer ' . currBuff - endfunction - - " like windo but restore the current window - function! WinDo(command) - let currwin=winnr() - execute 'windo ' . a:command - execute currwin . 'wincmd w' - endfunction -]], true) - -keymap.set('n', 'c', [[:call TabDo('set cursorline!')]], {silent = true}) +keymap.set('n', 'c', create_function_tabdo('set cursorline!'), {silent = true}) keymap.set('n', '/', [[:set invhlsearch]], {silent = true}) @@ -92,18 +77,34 @@ function create_autocmd_filetype(func) ) end -function create_func(ft, cmd) +function set_keymap_run_script(cmd) + cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) + keymap.set("n", "rr", cmd_string, {silent = true}) +end + +function create_function_create_autocmd_filetype(ft, cmd) return function() if vim.bo.filetype == ft then - cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) - keymap.set("n", "rr", cmd_string, {silent = true}) + set_keymap_run_script(cmd) end end end -create_autocmd_filetype(create_func('python', 'python3')) -create_autocmd_filetype(create_func('go', 'go run')) -create_autocmd_filetype(create_func('rust', 'cargo run')) +function create_function_create_autocmd_filename(fn, cmd) + return function() + if vim.fn.expand('%:t') == fn then + set_keymap_run_script(cmd) + end + end +end + + +create_autocmd_filetype(create_function_create_autocmd_filetype('python', 'python3')) +create_autocmd_filetype(create_function_create_autocmd_filetype('go', 'go run')) +create_autocmd_filetype(create_function_create_autocmd_filetype('rust', 'cargo run')) +create_autocmd_filetype(create_function_create_autocmd_filetype('markdown', 'glow')) + +create_autocmd_filetype(create_function_create_autocmd_filename('manpage', 'man -P cat -l')) @@ -112,23 +113,26 @@ create_autocmd_filetype(create_func('rust', 'cargo run')) vim.opt.number = true vim.opt.relativenumber = true -vim.api.nvim_exec([[ -function! ToggleRelativeAbsoluteNumber() - if !&number && !&relativenumber - set number - set norelativenumber - elseif &number && !&relativenumber - set nonumber - set relativenumber - elseif !&number && &relativenumber - set number - set relativenumber - elseif &number && &relativenumber - set nonumber - set norelativenumber - endif -endfunction -]], true) + +function toggle_number_style() + + local number = vim.opt.number["_value"] + local relativenumber = vim.opt.relativenumber["_value"] + + if (not number) and (not relativenumber) then + vim.opt.number = true + vim.opt.relativenumber = false + elseif (number) and (not relativenumber) then + vim.opt.number = false + vim.opt.relativenumber = true + elseif (not number) and (relativenumber) then + vim.opt.number = true + vim.opt.relativenumber = true + elseif (number) and (relativenumber) then + vim.opt.number = false + vim.opt.relativenumber = false + end +end -- Toggle line number style -keymap.set('n', 'l', [[:call TabDo('call ToggleRelativeAbsoluteNumber()') ]], {silent = true}) +keymap.set('n', 'l', create_function_tabdo('lua toggle_number_style()'), {silent = true}) From 007027ff697cdf7cd8030af4c49d65d2fa71226e Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 17 Jan 2023 18:52:14 +0300 Subject: [PATCH 33/76] ref(nvim) --- Makefile | 2 +- sub/nvim/after/plugin/cmp.lua | 18 ------------------ sub/nvim/after/plugin/colorscheme.lua | 2 +- sub/nvim/lua/base/base.lua | 21 +++++++++++++-------- sub/nvim/lua/base/maps.lua | 25 +++++++++++++------------ sub/nvim/lua/base/plugins.lua | 19 ++++++++----------- 6 files changed, 36 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index 4a0f409..866b0a3 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ nvim: ln -s $(PWD)/sub/nvim ~/.config/nvim ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim - nvim +PackerCompile +PackerClean +PackerInstall +PackerUpdate +PackerUpdate +qall + nvim +PackerCompile +PackerClean +PackerUpdate +PackerUpdate +qall ssh: cat $(PWD)/sub/ssh/config >> ~/.ssh/config diff --git a/sub/nvim/after/plugin/cmp.lua b/sub/nvim/after/plugin/cmp.lua index b09b7b6..3393733 100644 --- a/sub/nvim/after/plugin/cmp.lua +++ b/sub/nvim/after/plugin/cmp.lua @@ -25,24 +25,6 @@ cmp.setup { 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' }, diff --git a/sub/nvim/after/plugin/colorscheme.lua b/sub/nvim/after/plugin/colorscheme.lua index 4b64ef0..0a0f807 100644 --- a/sub/nvim/after/plugin/colorscheme.lua +++ b/sub/nvim/after/plugin/colorscheme.lua @@ -2,4 +2,4 @@ local status, autosave = pcall(require, "gruvbox") if (not status) then return end -vim.api.nvim_exec('colorscheme gruvbox', true) +vim.cmd.colorscheme("gruvbox") diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/base.lua index 1e2ff3e..8c236fb 100644 --- a/sub/nvim/lua/base/base.lua +++ b/sub/nvim/lua/base/base.lua @@ -81,16 +81,16 @@ vim.opt.cursorline = true -vim.cmd([[let &t_SI.="\e[5 q"]]) -vim.cmd([[let &t_SR.="\e[3 q"]]) -vim.cmd([[let &t_EI.="\e[1 q"]]) +vim.t_SI = [[\e[5 q]] +vim.t_SR = [[\e[3 q]] +vim.t_EI = [[\e[1 q]] -vim.cmd([[let g:netrw_banner = 0]]) -- hide banner -vim.cmd([[let g:netrw_liststyle = 3]]) -- tree instead of plain view -vim.cmd([[let g:netrw_browse_split = 0]]) -vim.cmd([[let g:netrw_winsize = 15]]) -vim.cmd([[let g:netrw_keepdir = 0]]) +vim.g.netrw_banner = 0 -- hide banner +vim.g.netrw_liststyle = 3 -- tree instead of plain view +vim.g.netrw_browse_split = 0 +vim.g.netrw_winsize = 15 +vim.g.netrw_keepdir = 0 -- Highlight yanked text for a while @@ -100,3 +100,8 @@ vim.api.nvim_create_autocmd("TextYankPost", { vim.highlight.on_yank() end, }) + +vim.cmd.highlight({ "DiagnosticError", "guifg=Grey" }) +vim.cmd.highlight({ "DiagnosticWarn", "guifg=Grey" }) +vim.cmd.highlight({ "DiagnosticInfo", "guifg=Grey" }) +vim.cmd.highlight({ "DiagnosticHint", "guifg=Grey" }) diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua index 7f4f527..e489e99 100644 --- a/sub/nvim/lua/base/maps.lua +++ b/sub/nvim/lua/base/maps.lua @@ -6,21 +6,23 @@ vim.g.mapleader = ',' function create_function_tabdo(command) return function() - local currTab = vim.fn.tabpagenr() - vim.cmd(string.format([[tabdo %s]], command)) - vim.cmd(string.format([[tabn %s]], currTab)) + local curr_tab = vim.fn.tabpagenr() + vim.cmd.tabdo(command) + vim.cmd.tabn(curr_tab) end end +-- Toggle line highlighting keymap.set('n', 'c', create_function_tabdo('set cursorline!'), {silent = true}) -keymap.set('n', '/', [[:set invhlsearch]], {silent = true}) +keymap.set('n', '/', + function() vim.opt.hlsearch = not vim.opt.hlsearch["_value"] end, + {silent = true}) keymap.set('i', 'jk', '', {silent = true}) keymap.set('i', 'ол', '', {silent = true}) - -- x to blackhole keymap.set('n', 'x', '"_x', {silent = true}) @@ -29,16 +31,15 @@ keymap.set('n', '+', '', {silent = true}) keymap.set('n', '-', '', {silent = true}) -- map \ to prev finding -keymap.set('n', [[\]], ',', {silent = true}) -keymap.set('v', [[\]], ',', {silent = true}) +keymap.set({"n", "v"}, [[\]], ',', {silent = true}) -- Select all keymap.set('n', '', 'ggG', {silent = true}) -- Scroll tabs -keymap.set("n", '', ':tabnext', {silent = true}) -keymap.set("n", '', ':tabprev', {silent = true}) +keymap.set("n", '', vim.cmd.tabnext, {silent = true}) +keymap.set("n", '', vim.cmd.tabprev, {silent = true}) -- Kill current buffer @@ -70,7 +71,7 @@ vim.api.nvim_create_user_command('Sw', [[execute 'silent! write !SUDO_ASKPASS=$( function create_autocmd_filetype(func) - create_autocmd = vim.api.nvim_create_autocmd + local create_autocmd = vim.api.nvim_create_autocmd create_autocmd("BufEnter", { pattern = '*', callback = func} @@ -78,7 +79,7 @@ function create_autocmd_filetype(func) end function set_keymap_run_script(cmd) - cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) + local cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) keymap.set("n", "rr", cmd_string, {silent = true}) end @@ -99,6 +100,7 @@ function create_function_create_autocmd_filename(fn, cmd) end +-- Run current file by type create_autocmd_filetype(create_function_create_autocmd_filetype('python', 'python3')) create_autocmd_filetype(create_function_create_autocmd_filetype('go', 'go run')) create_autocmd_filetype(create_function_create_autocmd_filetype('rust', 'cargo run')) @@ -108,7 +110,6 @@ create_autocmd_filetype(create_function_create_autocmd_filename('manpage', 'man - -- Toggle line number style vim.opt.number = true vim.opt.relativenumber = true diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 3572108..de9cbfc 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -15,13 +15,16 @@ return require('packer').startup(function(use) use 'preservim/vimux' use 'rbgrouleff/bclose.vim' use 'frazrepo/vim-rainbow' + use 'mattn/emmet-vim' + use 'Pocco81/auto-save.nvim' + use 'windwp/nvim-autopairs' + use 'powerman/vim-plugin-ruscmd' -- Russian navigation + use 'lewis6991/gitsigns.nvim' + use 'windwp/nvim-ts-autotag' + use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } -- requiered patch your font use 'ryanoasis/vim-devicons' - use 'powerman/vim-plugin-ruscmd' -- Russian navigation - - use 'Pocco81/auto-save.nvim' - use 'windwp/nvim-autopairs' -- pyright use 'neovim/nvim-lspconfig' @@ -29,15 +32,9 @@ return require('packer').startup(function(use) use 'hrsh7th/cmp-nvim-lsp' use 'saadparwaiz1/cmp_luasnip' use 'L3MON4D3/LuaSnip' - use 'nvim-lua/plenary.nvim' use { 'nvim-telescope/telescope.nvim', - requires = { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = false } + requires = {{'nvim-lua/plenary.nvim'}, { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = false }} } - use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - - use 'lewis6991/gitsigns.nvim' - use 'windwp/nvim-ts-autotag' - end) From e3de3005da1e8bab3f0fa002a108735e89de9d24 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 17 Jan 2023 19:26:57 +0300 Subject: [PATCH 34/76] add(nvim): plugins --- sub/nvim/init.lua | 3 --- sub/nvim/lua/base/base.lua | 14 ++++++++------ sub/nvim/lua/base/maps.lua | 1 + sub/nvim/lua/base/plugins.lua | 6 ++++++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sub/nvim/init.lua b/sub/nvim/init.lua index 560a6b6..15eb074 100644 --- a/sub/nvim/init.lua +++ b/sub/nvim/init.lua @@ -1,4 +1 @@ - require("base.sourcer") - - diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/base.lua index 8c236fb..cb8e9fd 100644 --- a/sub/nvim/lua/base/base.lua +++ b/sub/nvim/lua/base/base.lua @@ -77,13 +77,12 @@ vim.opt.ffs = 'unix,mac' vim.opt.path:append { '**' } -- Finding files - Search down into subfolders -vim.opt.cursorline = true - - -vim.t_SI = [[\e[5 q]] -vim.t_SR = [[\e[3 q]] -vim.t_EI = [[\e[1 q]] +vim.cmd([[ + let &t_SI.="\e[5 q" "SI = режим вставки + let &t_SR.="\e[3 q" "SR = режим замены + let &t_EI.="\e[1 q" "EI = нормальный режим +]]) vim.g.netrw_banner = 0 -- hide banner @@ -101,6 +100,9 @@ vim.api.nvim_create_autocmd("TextYankPost", { end, }) +-- dont auto commenting new lines +vim.api.nvim_create_autocmd("BufEnter", {pattern = "*", command = [[set fo-=c fo-=r fo-=o]]}) + vim.cmd.highlight({ "DiagnosticError", "guifg=Grey" }) vim.cmd.highlight({ "DiagnosticWarn", "guifg=Grey" }) vim.cmd.highlight({ "DiagnosticInfo", "guifg=Grey" }) diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua index e489e99..3631b11 100644 --- a/sub/nvim/lua/base/maps.lua +++ b/sub/nvim/lua/base/maps.lua @@ -13,6 +13,7 @@ function create_function_tabdo(command) end -- Toggle line highlighting +vim.opt.cursorline = true keymap.set('n', 'c', create_function_tabdo('set cursorline!'), {silent = true}) keymap.set('n', '/', diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index de9cbfc..b3d6e59 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -9,6 +9,8 @@ return require('packer').startup(function(use) use 'ellisonleao/gruvbox.nvim' use 'tpope/vim-surround' + use 'tpope/vim-repeat' + use 'google/vim-searchindex' use 'tpope/vim-commentary' use 'ap/vim-css-color' use 'preservim/tagbar' @@ -23,6 +25,10 @@ return require('packer').startup(function(use) use 'windwp/nvim-ts-autotag' use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } + use { 'numToStr/Comment.nvim', + config = function() require('Comment').setup() end + } + -- requiered patch your font use 'ryanoasis/vim-devicons' From b6cf8738211ed0df1f20801488a45f09bcb2ca8d Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 17 Jan 2023 19:56:43 +0300 Subject: [PATCH 35/76] add(nvim): telescope config --- sub/nvim/after/plugin/telescope.lua | 57 +++++++++++++++++++++++++++++ sub/nvim/lua/base/maps.lua | 39 ++++++++++---------- 2 files changed, 77 insertions(+), 19 deletions(-) diff --git a/sub/nvim/after/plugin/telescope.lua b/sub/nvim/after/plugin/telescope.lua index a5cf702..eab4399 100644 --- a/sub/nvim/after/plugin/telescope.lua +++ b/sub/nvim/after/plugin/telescope.lua @@ -3,3 +3,60 @@ local status, telescope = pcall(require, "telescope") if (not status) then return end telescope.load_extension('fzf') + +telescope.setup { + defaults = { + selection_caret = " ", + path_display = { "smart" }, + file_ignore_patterns = { + ".git/", + "target/", + "docs/", + "vendor/*", + "%.lock", + "pycache/*", + "%.sqlite3", + "%.ipynb", + "node_modules/*", + "%.svg", + "%.otf", + "%.ttf", + "%.webp", + ".dart_tool/", + ".github/", + ".gradle/", + ".idea/", + ".settings/", + ".vscode/", + "pycache/", + "build/", + "env/", + "gradle/", + "node_modules/", + "%.pdb", + "%.dll", + "%.class", + "%.exe", + "%.cache", + "%.ico", + "%.pdf", + "%.dylib", + "%.jar", + "%.docx", + "%.met", + "smalljre_*/*", + ".vale/", + "%.burp", + "%.mp4", + "%.mkv", + "%.rar", + "%.zip", + "%.7z", + "%.tar", + "%.bz2", + "%.epub", + "%.flac", + "%.tar.gz", + }, + } +} diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua index 3631b11..710a040 100644 --- a/sub/nvim/lua/base/maps.lua +++ b/sub/nvim/lua/base/maps.lua @@ -3,6 +3,7 @@ local keymap = vim.keymap vim.g.mapleader = ',' +local opts = { noremap = true, silent = true } function create_function_tabdo(command) return function() @@ -14,52 +15,52 @@ end -- Toggle line highlighting vim.opt.cursorline = true -keymap.set('n', 'c', create_function_tabdo('set cursorline!'), {silent = true}) +keymap.set('n', 'c', create_function_tabdo('set cursorline!'), opts) keymap.set('n', '/', function() vim.opt.hlsearch = not vim.opt.hlsearch["_value"] end, - {silent = true}) + opts) -keymap.set('i', 'jk', '', {silent = true}) -keymap.set('i', 'ол', '', {silent = true}) +keymap.set('i', 'jk', '', opts) +keymap.set('i', 'ол', '', opts) -- x to blackhole -keymap.set('n', 'x', '"_x', {silent = true}) +keymap.set('n', 'x', '"_x', opts) -- Increment/decrement -keymap.set('n', '+', '', {silent = true}) -keymap.set('n', '-', '', {silent = true}) +keymap.set('n', '+', '', opts) +keymap.set('n', '-', '', opts) -- map \ to prev finding -keymap.set({"n", "v"}, [[\]], ',', {silent = true}) +keymap.set({"n", "v"}, [[\]], ',', opts) -- Select all -keymap.set('n', '', 'ggG', {silent = true}) +keymap.set('n', '', 'ggG', opts) -- Scroll tabs -keymap.set("n", '', vim.cmd.tabnext, {silent = true}) -keymap.set("n", '', vim.cmd.tabprev, {silent = true}) +keymap.set("n", '', vim.cmd.tabnext, opts) +keymap.set("n", '', vim.cmd.tabprev, opts) -- Kill current buffer -keymap.set("n", 'qq', ':bd!', {silent = true}) +keymap.set("n", 'qq', ':bd!', opts) -- Quick exit without saving -keymap.set("n", 'qa', ':qa!', {silent = true}) +keymap.set("n", 'qa', ':qa!', opts) -keymap.set("n", 'eh', ':set list!', {silent = true}) +keymap.set("n", 'eh', ':set list!', opts) vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]] -- Tags panel (ctags required) -keymap.set("n", 't', ':TagbarToggle', {silent = true}) +keymap.set("n", 't', ':TagbarToggle', opts) -- Telescope -keymap.set("n", 'ff', 'Telescope find_files', {silent = true}) -keymap.set("n", 'fg', 'Telescope live_grep', {silent = true}) +keymap.set("n", 'ff', 'Telescope find_files', opts) +keymap.set("n", 'fg', 'Telescope live_grep', opts) -- Expand %% to dirname of current file in command line @@ -81,7 +82,7 @@ end function set_keymap_run_script(cmd) local cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) - keymap.set("n", "rr", cmd_string, {silent = true}) + keymap.set("n", "rr", cmd_string, opts) end function create_function_create_autocmd_filetype(ft, cmd) @@ -137,4 +138,4 @@ function toggle_number_style() end -- Toggle line number style -keymap.set('n', 'l', create_function_tabdo('lua toggle_number_style()'), {silent = true}) +keymap.set('n', 'l', create_function_tabdo('lua toggle_number_style()'), opts) From 93378899686813500db8007c5db2be29fff168ab Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 17 Jan 2023 22:33:18 +0300 Subject: [PATCH 36/76] ref(nvim) rename packages --- sub/nvim/init.lua | 2 +- sub/nvim/lua/base/{sourcer.lua => init.lua} | 4 +--- sub/nvim/lua/base/{base.lua => options.lua} | 0 sub/nvim/lua/base/plugins.lua | 4 ---- 4 files changed, 2 insertions(+), 8 deletions(-) rename sub/nvim/lua/base/{sourcer.lua => init.lua} (65%) rename sub/nvim/lua/base/{base.lua => options.lua} (100%) diff --git a/sub/nvim/init.lua b/sub/nvim/init.lua index 15eb074..d3c1589 100644 --- a/sub/nvim/init.lua +++ b/sub/nvim/init.lua @@ -1 +1 @@ -require("base.sourcer") +require("base") diff --git a/sub/nvim/lua/base/sourcer.lua b/sub/nvim/lua/base/init.lua similarity index 65% rename from sub/nvim/lua/base/sourcer.lua rename to sub/nvim/lua/base/init.lua index bf1b36b..541cd72 100644 --- a/sub/nvim/lua/base/sourcer.lua +++ b/sub/nvim/lua/base/init.lua @@ -1,5 +1,3 @@ - -require("base.base") +require("base.options") require("base.maps") require("base.plugins") - diff --git a/sub/nvim/lua/base/base.lua b/sub/nvim/lua/base/options.lua similarity index 100% rename from sub/nvim/lua/base/base.lua rename to sub/nvim/lua/base/options.lua diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index b3d6e59..05809f0 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -1,5 +1,4 @@ return require('packer').startup(function(use) - -- Packer can manage itself use 'wbthomason/packer.nvim' use { @@ -29,9 +28,6 @@ return require('packer').startup(function(use) config = function() require('Comment').setup() end } - -- requiered patch your font - use 'ryanoasis/vim-devicons' - -- pyright use 'neovim/nvim-lspconfig' use 'hrsh7th/nvim-cmp' From 05f6385865e734dd3b372c2838d8ced540369452 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 18 Jan 2023 18:51:09 +0300 Subject: [PATCH 37/76] ref nvim --- README.md | 3 - sub/nvim/lua/base/init.lua | 2 +- sub/nvim/lua/base/keys/init.lua | 2 + sub/nvim/lua/base/keys/keys.lua | 97 +++++++++++++++++ sub/nvim/lua/base/keys/run-scripts.lua | 59 +++++++++++ sub/nvim/lua/base/maps.lua | 141 ------------------------- sub/nvim/lua/base/options.lua | 116 ++++++++++---------- 7 files changed, 222 insertions(+), 198 deletions(-) create mode 100644 sub/nvim/lua/base/keys/init.lua create mode 100644 sub/nvim/lua/base/keys/keys.lua create mode 100644 sub/nvim/lua/base/keys/run-scripts.lua delete mode 100644 sub/nvim/lua/base/maps.lua diff --git a/README.md b/README.md index 4682b43..210e1ee 100644 --- a/README.md +++ b/README.md @@ -80,9 +80,6 @@ echo "Hello $USER!" | ,rr | Run script in new tab (python, go, preview markdown)| | ,rm | Run script (make run) | | ,rf | Format file (go) | -| ,nn | Toggle NerdTree | -| ,nf | Toggle NerdTree focus | -| ,ve | Open ~/.vimrc or ~/.config/nvim/init.vim in new tab | diff --git a/sub/nvim/lua/base/init.lua b/sub/nvim/lua/base/init.lua index 541cd72..083e923 100644 --- a/sub/nvim/lua/base/init.lua +++ b/sub/nvim/lua/base/init.lua @@ -1,3 +1,3 @@ require("base.options") -require("base.maps") +require("base.keys") require("base.plugins") diff --git a/sub/nvim/lua/base/keys/init.lua b/sub/nvim/lua/base/keys/init.lua new file mode 100644 index 0000000..28829fd --- /dev/null +++ b/sub/nvim/lua/base/keys/init.lua @@ -0,0 +1,2 @@ +require("base.keys.keys") +require("base.keys.run-scripts") diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua new file mode 100644 index 0000000..2649472 --- /dev/null +++ b/sub/nvim/lua/base/keys/keys.lua @@ -0,0 +1,97 @@ +local map = vim.keymap.set +local opts = { noremap = true, silent = true } + + +vim.g.mapleader = ',' + + +function create_function_tabdo(command) + return function() + local curr_tab = vim.fn.tabpagenr() + vim.cmd.tabdo(command) + vim.cmd.tabn(curr_tab) + end +end + +-- Toggle line highlighting +map('n', 'c', create_function_tabdo('set cursorline!'), opts) + +map('n', '/', + function() vim.opt.hlsearch = not vim.opt.hlsearch["_value"] end, + opts) + +map('i', 'jk', '', opts) +map('i', 'ол', '', opts) + + +-- x to blackhole +map('n', 'x', '"_x', opts) + +-- Increment/decrement +map('n', '+', '', opts) +map('n', '-', '', opts) + +-- map \ to prev finding +map({"n", "v"}, [[\]], ',', opts) + +-- Select all +map('n', '', 'ggG', opts) + + +-- Scroll tabs +map("n", '', vim.cmd.tabnext, opts) +map("n", '', vim.cmd.tabprev, opts) + + +-- Kill current buffer +map("n", 'qq', ':bd!', opts) +-- Quick exit without saving +map("n", 'qa', ':qa!', opts) + + +map("n", 'eh', ':set list!', opts) +vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]] + + +-- Tags panel (ctags required) +map("n", 't', ':TagbarToggle', opts) + + +-- Telescope +map("n", 'ff', 'Telescope find_files', opts) +map("n", 'fg', 'Telescope live_grep', opts) + + +-- Expand %% to dirname of current file in command line +map("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true}) + + +-- Save from root +vim.api.nvim_create_user_command('Sw', [[execute 'silent! write !SUDO_ASKPASS=$(which vim_askpass_helper) sudo -A tee % >/dev/null']], {}) + + + +-- Toggle line number style +function toggle_number_style() + + local opt = vim.opt + local number = opt.number["_value"] + local relativenumber = opt.relativenumber["_value"] + + if (not number) and (not relativenumber) then + opt.number = true + opt.relativenumber = false + elseif (number) and (not relativenumber) then + opt.number = false + opt.relativenumber = true + elseif (not number) and (relativenumber) then + opt.number = true + opt.relativenumber = true + elseif (number) and (relativenumber) then + opt.number = false + opt.relativenumber = false + end +end + +-- Toggle line number style +map('n', 'l', create_function_tabdo('lua toggle_number_style()'), opts) diff --git a/sub/nvim/lua/base/keys/run-scripts.lua b/sub/nvim/lua/base/keys/run-scripts.lua new file mode 100644 index 0000000..b470419 --- /dev/null +++ b/sub/nvim/lua/base/keys/run-scripts.lua @@ -0,0 +1,59 @@ + +function autocmd(func) + local create_autocmd = vim.api.nvim_create_autocmd + + create_autocmd("BufEnter", + { pattern = '*', callback = func} + ) +end + +function set_keymap_base(key, cmd) + local map = vim.keymap.set + keymap_keys = string.format([[r%s]], key) + map("n", keymap_keys, cmd, opts) +end + +function set_keymap_format_file(cmd) + local cmd_string = string.format([[:!%s %% ]], cmd) + set_keymap_base("f", cmd_string) +end + +function set_keymap_run_script(cmd) + local cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) + set_keymap_base("r", cmd_string) +end + +function create_function_autocmd_filetype(set_keymap_func, ft, cmd) + return function() + if vim.bo.filetype == ft then + set_keymap_func(cmd) + end + end +end + +function create_function_autocmd_filename(set_keymap_func, fn, cmd) + return function() + if vim.fn.expand('%:t') == fn then + set_keymap_func(cmd) + end + end +end + +function autocmd_run_script_filetype(ft, cmd) + autocmd(create_function_autocmd_filetype(set_keymap_run_script, ft, cmd)) +end + +function autocmd_format_file_by_filetype(ft, cmd) + autocmd(create_function_autocmd_filetype(set_keymap_format_file, ft, cmd)) +end + + +autocmd_run_script_filetype('python', 'python3') +autocmd_run_script_filetype('go', 'go run') +autocmd_run_script_filetype('rust', 'cargo run') +autocmd_run_script_filetype('markdown', 'glow') + +autocmd(create_function_autocmd_filename(set_keymap_run_script, 'manpage', 'man -P cat -l')) + +autocmd_format_file_by_filetype('rust', 'cargo fmt -p') +autocmd_format_file_by_filetype('go', 'go fmt') diff --git a/sub/nvim/lua/base/maps.lua b/sub/nvim/lua/base/maps.lua deleted file mode 100644 index 710a040..0000000 --- a/sub/nvim/lua/base/maps.lua +++ /dev/null @@ -1,141 +0,0 @@ -local keymap = vim.keymap - - -vim.g.mapleader = ',' - -local opts = { noremap = true, silent = true } - -function create_function_tabdo(command) - return function() - local curr_tab = vim.fn.tabpagenr() - vim.cmd.tabdo(command) - vim.cmd.tabn(curr_tab) - end -end - --- Toggle line highlighting -vim.opt.cursorline = true -keymap.set('n', 'c', create_function_tabdo('set cursorline!'), opts) - -keymap.set('n', '/', - function() vim.opt.hlsearch = not vim.opt.hlsearch["_value"] end, - opts) - -keymap.set('i', 'jk', '', opts) -keymap.set('i', 'ол', '', opts) - - --- x to blackhole -keymap.set('n', 'x', '"_x', opts) - --- Increment/decrement -keymap.set('n', '+', '', opts) -keymap.set('n', '-', '', opts) - --- map \ to prev finding -keymap.set({"n", "v"}, [[\]], ',', opts) - --- Select all -keymap.set('n', '', 'ggG', opts) - - --- Scroll tabs -keymap.set("n", '', vim.cmd.tabnext, opts) -keymap.set("n", '', vim.cmd.tabprev, opts) - - --- Kill current buffer -keymap.set("n", 'qq', ':bd!', opts) --- Quick exit without saving -keymap.set("n", 'qa', ':qa!', opts) - - -keymap.set("n", 'eh', ':set list!', opts) -vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]] - - --- Tags panel (ctags required) -keymap.set("n", 't', ':TagbarToggle', opts) - - --- Telescope -keymap.set("n", 'ff', 'Telescope find_files', opts) -keymap.set("n", 'fg', 'Telescope live_grep', opts) - - --- Expand %% to dirname of current file in command line -keymap.set("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true}) - - --- Save from root -vim.api.nvim_create_user_command('Sw', [[execute 'silent! write !SUDO_ASKPASS=$(which vim_askpass_helper) sudo -A tee % >/dev/null']], {}) - - - -function create_autocmd_filetype(func) - local create_autocmd = vim.api.nvim_create_autocmd - - create_autocmd("BufEnter", - { pattern = '*', callback = func} - ) -end - -function set_keymap_run_script(cmd) - local cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) - keymap.set("n", "rr", cmd_string, opts) -end - -function create_function_create_autocmd_filetype(ft, cmd) - return function() - if vim.bo.filetype == ft then - set_keymap_run_script(cmd) - end - end -end - -function create_function_create_autocmd_filename(fn, cmd) - return function() - if vim.fn.expand('%:t') == fn then - set_keymap_run_script(cmd) - end - end -end - - --- Run current file by type -create_autocmd_filetype(create_function_create_autocmd_filetype('python', 'python3')) -create_autocmd_filetype(create_function_create_autocmd_filetype('go', 'go run')) -create_autocmd_filetype(create_function_create_autocmd_filetype('rust', 'cargo run')) -create_autocmd_filetype(create_function_create_autocmd_filetype('markdown', 'glow')) - -create_autocmd_filetype(create_function_create_autocmd_filename('manpage', 'man -P cat -l')) - - - --- Toggle line number style -vim.opt.number = true -vim.opt.relativenumber = true - - -function toggle_number_style() - - local number = vim.opt.number["_value"] - local relativenumber = vim.opt.relativenumber["_value"] - - if (not number) and (not relativenumber) then - vim.opt.number = true - vim.opt.relativenumber = false - elseif (number) and (not relativenumber) then - vim.opt.number = false - vim.opt.relativenumber = true - elseif (not number) and (relativenumber) then - vim.opt.number = true - vim.opt.relativenumber = true - elseif (number) and (relativenumber) then - vim.opt.number = false - vim.opt.relativenumber = false - end -end - --- Toggle line number style -keymap.set('n', 'l', create_function_tabdo('lua toggle_number_style()'), opts) diff --git a/sub/nvim/lua/base/options.lua b/sub/nvim/lua/base/options.lua index cb8e9fd..f81ed28 100644 --- a/sub/nvim/lua/base/options.lua +++ b/sub/nvim/lua/base/options.lua @@ -1,64 +1,74 @@ +local opt = vim.opt -vim.opt.ruler = true +opt.ruler = true +opt.encoding = 'utf-8' +opt.fileencoding = 'utf-8' + +opt.number = true +opt.relativenumber = true + +opt.clipboard:append { 'unnamedplus' } +opt.shell = 'bash' + +opt.ttimeoutlen = 0 + +vim.cmd([[ + filetype plugin indent on +]]) + +vim.cmd([[ + syntax enable +]]) + +opt.compatible = false + +opt.hidden = true + +opt.expandtab = true +opt.smarttab = true +opt.tabstop = 4 -vim.scriptencoding = 'utf-8' -vim.opt.encoding = 'utf-8' -vim.opt.fileencoding = 'utf-8' +opt.cursorline = true +opt.softtabstop = 4 +opt.shiftwidth = 4 +opt.autoindent = true +opt.smartindent = true +opt.wrap = false -vim.opt.clipboard:append { 'unnamedplus' } -vim.opt.shell = 'bash' - -vim.opt.ttimeoutlen = 0 - -vim.opt.compatible = false - -vim.opt.hidden = true - -vim.opt.expandtab = true -vim.opt.smarttab = true -vim.opt.tabstop = 4 +opt.ttyfast = true +opt.autoread = true -vim.opt.softtabstop = 4 -vim.opt.shiftwidth = 4 -vim.opt.autoindent = true -vim.opt.smartindent = true -vim.opt.wrap = false +opt.errorbells = false +opt.visualbell = false +opt.showcmd = true +opt.showtabline = 2 -vim.opt.ttyfast = true -vim.opt.autoread = true +opt.smartcase = true -- if search line hasn`t Upper case chars - ignore case search, else case-sensivity search +opt.incsearch = true + +opt.mousehide = true +opt.mouse = 'a' + +opt.colorcolumn = '81' +opt.scrolloff = 7 -vim.opt.errorbells = false -vim.opt.visualbell = false -vim.opt.showcmd = true -vim.opt.showtabline = 2 +opt.termguicolors = true +opt.background = 'dark' -vim.opt.smartcase = true -- if search line hasn`t Upper case chars - ignore case search, else case-sensivity search -vim.opt.incsearch = true - -vim.opt.mousehide = true -vim.opt.mouse = 'a' - -vim.opt.colorcolumn = '81' -vim.opt.scrolloff = 7 - - -vim.opt.termguicolors = true -vim.opt.background = 'dark' - -vim.opt.backup = true -vim.opt.swapfile = false -vim.opt.undofile = true -vim.opt.history = 1000 -vim.opt.undoreload = 1000 +opt.backup = true +opt.swapfile = false +opt.undofile = true +opt.history = 1000 +opt.undoreload = 1000 local prefix = vim.fn.expand("~/.cache/nvim/tmp") -vim.opt.undodir = { prefix .. "/undo//" } -vim.opt.backupdir = { prefix .. "/backup//" } -vim.opt.directory = { prefix .. "/swp//" } +opt.undodir = { prefix .. "/undo//" } +opt.backupdir = { prefix .. "/backup//" } +opt.directory = { prefix .. "/swp//" } function makeDirIfNoExists(path) @@ -69,13 +79,13 @@ function makeDirIfNoExists(path) end -- make this dirs if no exists previously -makeDirIfNoExists(vim.opt.undodir) -makeDirIfNoExists(vim.opt.backupdir) -makeDirIfNoExists(vim.opt.directory) +makeDirIfNoExists(opt.undodir) +makeDirIfNoExists(opt.backupdir) +makeDirIfNoExists(opt.directory) -vim.opt.ffs = 'unix,mac' +opt.ffs = 'unix,mac' -vim.opt.path:append { '**' } -- Finding files - Search down into subfolders +opt.path:append { '**' } -- Finding files - Search down into subfolders vim.cmd([[ From 85b0441e57a7b29a095f05cdbeccf64448a5e94a Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 18 Jan 2023 21:45:14 +0300 Subject: [PATCH 38/76] add nvim plugins --- sub/nvim/lua/base/plugins.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 05809f0..5b65478 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -22,6 +22,11 @@ return require('packer').startup(function(use) use 'powerman/vim-plugin-ruscmd' -- Russian navigation use 'lewis6991/gitsigns.nvim' use 'windwp/nvim-ts-autotag' + use 'lervag/vimtex' + use { + 'shime/vim-livedown', -- Markdown previewer :LivedownPreview + run = '/usr/bin/npm install -g livedown' + } use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } use { 'numToStr/Comment.nvim', @@ -37,6 +42,9 @@ return require('packer').startup(function(use) use { 'nvim-telescope/telescope.nvim', - requires = {{'nvim-lua/plenary.nvim'}, { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = false }} + requires = { + { 'nvim-lua/plenary.nvim' }, + { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = false } + } } end) From 360a93c6d1a0ff6c807b9defd1ef7ef384435c25 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 18 Jan 2023 22:01:51 +0300 Subject: [PATCH 39/76] nvim local functions --- sub/nvim/lua/base/keys/keys.lua | 2 +- sub/nvim/lua/base/keys/run-scripts.lua | 16 ++++++++-------- sub/nvim/lua/base/options.lua | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index 2649472..a1bf8c8 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -5,7 +5,7 @@ local opts = { noremap = true, silent = true } vim.g.mapleader = ',' -function create_function_tabdo(command) +local function create_function_tabdo(command) return function() local curr_tab = vim.fn.tabpagenr() vim.cmd.tabdo(command) diff --git a/sub/nvim/lua/base/keys/run-scripts.lua b/sub/nvim/lua/base/keys/run-scripts.lua index b470419..dbb4bda 100644 --- a/sub/nvim/lua/base/keys/run-scripts.lua +++ b/sub/nvim/lua/base/keys/run-scripts.lua @@ -1,5 +1,5 @@ -function autocmd(func) +local function autocmd(func) local create_autocmd = vim.api.nvim_create_autocmd create_autocmd("BufEnter", @@ -7,23 +7,23 @@ function autocmd(func) ) end -function set_keymap_base(key, cmd) +local function set_keymap_base(key, cmd) local map = vim.keymap.set keymap_keys = string.format([[r%s]], key) map("n", keymap_keys, cmd, opts) end -function set_keymap_format_file(cmd) +local function set_keymap_format_file(cmd) local cmd_string = string.format([[:!%s %% ]], cmd) set_keymap_base("f", cmd_string) end -function set_keymap_run_script(cmd) +local function set_keymap_run_script(cmd) local cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) set_keymap_base("r", cmd_string) end -function create_function_autocmd_filetype(set_keymap_func, ft, cmd) +local function create_function_autocmd_filetype(set_keymap_func, ft, cmd) return function() if vim.bo.filetype == ft then set_keymap_func(cmd) @@ -31,7 +31,7 @@ function create_function_autocmd_filetype(set_keymap_func, ft, cmd) end end -function create_function_autocmd_filename(set_keymap_func, fn, cmd) +local function create_function_autocmd_filename(set_keymap_func, fn, cmd) return function() if vim.fn.expand('%:t') == fn then set_keymap_func(cmd) @@ -39,11 +39,11 @@ function create_function_autocmd_filename(set_keymap_func, fn, cmd) end end -function autocmd_run_script_filetype(ft, cmd) +local function autocmd_run_script_filetype(ft, cmd) autocmd(create_function_autocmd_filetype(set_keymap_run_script, ft, cmd)) end -function autocmd_format_file_by_filetype(ft, cmd) +local function autocmd_format_file_by_filetype(ft, cmd) autocmd(create_function_autocmd_filetype(set_keymap_format_file, ft, cmd)) end diff --git a/sub/nvim/lua/base/options.lua b/sub/nvim/lua/base/options.lua index f81ed28..c758b2a 100644 --- a/sub/nvim/lua/base/options.lua +++ b/sub/nvim/lua/base/options.lua @@ -71,7 +71,7 @@ opt.backupdir = { prefix .. "/backup//" } opt.directory = { prefix .. "/swp//" } -function makeDirIfNoExists(path) +local function makeDirIfNoExists(path) local path = path["_value"] if (vim.fn.isdirectory(path) == 0) then vim.fn.mkdir(path, "p") From da64c088f725ff85c532a2b0ef17c2312823c7f0 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 19 Jan 2023 20:24:13 +0300 Subject: [PATCH 40/76] nvim russian commands --- profile | 4 +--- sub/nvim/lua/base/options.lua | 3 +++ sub/nvim/lua/base/plugins.lua | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/profile b/profile index c27545d..44204ce 100644 --- a/profile +++ b/profile @@ -1,7 +1,5 @@ -# if running bash if [ -n "$BASH_VERSION" ]; then - # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" + . "$HOME/.bashrc" fi fi diff --git a/sub/nvim/lua/base/options.lua b/sub/nvim/lua/base/options.lua index c758b2a..0a4e985 100644 --- a/sub/nvim/lua/base/options.lua +++ b/sub/nvim/lua/base/options.lua @@ -117,3 +117,6 @@ vim.cmd.highlight({ "DiagnosticError", "guifg=Grey" }) vim.cmd.highlight({ "DiagnosticWarn", "guifg=Grey" }) vim.cmd.highlight({ "DiagnosticInfo", "guifg=Grey" }) vim.cmd.highlight({ "DiagnosticHint", "guifg=Grey" }) + +-- Russian commands +opt.langmap = 'ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz' diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 5b65478..1852c79 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -19,7 +19,6 @@ return require('packer').startup(function(use) use 'mattn/emmet-vim' use 'Pocco81/auto-save.nvim' use 'windwp/nvim-autopairs' - use 'powerman/vim-plugin-ruscmd' -- Russian navigation use 'lewis6991/gitsigns.nvim' use 'windwp/nvim-ts-autotag' use 'lervag/vimtex' From cfdb0952cab91324dc697d22e2fb310768c9eb64 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 19 Jan 2023 21:55:20 +0300 Subject: [PATCH 41/76] i3status add headphones battery wrapper --- Makefile | 3 +- functions/i3status_wrapper.sh | 56 +++++++++++++++++++++++++++++++++++ sub/i3/config | 2 +- sub/i3/statusconfig | 44 ++++++++++++++++++--------- 4 files changed, 89 insertions(+), 16 deletions(-) create mode 100755 functions/i3status_wrapper.sh diff --git a/Makefile b/Makefile index 866b0a3..2ad88da 100644 --- a/Makefile +++ b/Makefile @@ -67,12 +67,13 @@ gpg: echo -e "default-cache-ttl 1\nmax-cache-ttl 1" > ~/.gnupg/gpg-agent.conf; echo RELOADAGENT | gpg-connect-agent i3: - @echo "sudo pacman -S nitrogen picom compton ttf-font-awesome xdotool xclip maim" + @echo "sudo pacman -S nitrogen picom jq compton ttf-font-awesome xdotool xclip maim" test -d ~/.config/i3 || \ mkdir -p ~/.config/i3 mkdir -p ~/.config/i3status ln -s $(PWD)/sub/i3/config ~/.config/i3/config ln -s $(PWD)/sub/i3/statusconfig ~/.config/i3status/config + ln -s $(PWD)/functions/i3status_wrapper.sh ~/.local/bin/i3status_wrapper.sh bat: test -d ~/.config/bat || \ diff --git a/functions/i3status_wrapper.sh b/functions/i3status_wrapper.sh new file mode 100755 index 0000000..76fb8ca --- /dev/null +++ b/functions/i3status_wrapper.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# The idea is to define "holder" modules in i3status config and then replace them + +# In order to make this example work you need to add +# order += "tztime holder__headphones" +# and +# tztime holder__headphones { +# format = "holder__headphones" +# } +# in i3staus config + +# Don't forget that i3status config should contain: +# general { +# output_format = i3bar +# } +# +# and i3 config should contain: +# bar { +# status_command exec /path/to/this/script.sh +# } + +# Make sure jq is installed + +# You can easily add multiple custom modules using additional "holders" + +function update_holder { + + local instance="$1" + local replacement="$2" + echo "$json_array" | jq --argjson arg_j "$replacement" "(.[] | (select(.instance==\"$instance\"))) |= \$arg_j" +} + +function remove_holder { + + local instance="$1" + echo "$json_array" | jq "del(.[] | (select(.instance==\"$instance\")))" +} + +function headphones { + + battery_status="$(bluetoothctl info 14:0A:29:0A:6A:2F | grep "Battery Percentage" | awk -F '[()]' '{ print "🎧"$2"%" }')" + + local json="{ \"full_text\": \"$battery_status\", \"color\": \"#FFFFFF\"}" + + json_array=$(update_holder holder__headphones "$json") + +} + +i3status | (read line; echo "$line"; read line ; echo "$line" ; read line ; echo "$line" ; while true +do + read line + json_array="$(echo $line | sed -e 's/^,//')" + headphones + echo ",$json_array" +done) diff --git a/sub/i3/config b/sub/i3/config index fa6f70b..af9c233 100644 --- a/sub/i3/config +++ b/sub/i3/config @@ -198,7 +198,7 @@ bindsym $mod+r mode "resize" # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { - status_command i3status + status_command exec ~/.local/bin/i3status_wrapper.sh tray_output DP-0 } diff --git a/sub/i3/statusconfig b/sub/i3/statusconfig index 1137991..f088b31 100644 --- a/sub/i3/statusconfig +++ b/sub/i3/statusconfig @@ -7,8 +7,9 @@ # If the above line is not correctly displayed, fix your editor first! general { - colors = true - interval = 5 + colors = true + interval = 5 + output_format = i3bar } order += "ipv6" @@ -20,38 +21,40 @@ order += "disk /home" order += "memory" order += "cpu_usage" order += "cpu_temperature 0" +order += "tztime holder__headphones" +order += "volume master" order += "tztime local" wireless _first_ { - format_up = " (%quality at %essid) %ip" - format_down = " down" + format_up = " (%quality at %essid) %ip" + format_down = " down" } ethernet _first_ { - format_up = " %ip" - format_down = " down" + format_up = " %ip" + format_down = " down" } battery all { - format = " %status %percentage %remaining" + format = " %status %percentage %remaining" } disk "/" { - format = "/ %used/%total" + format = "/ %used/%total" } disk "/home" { - format = " %used/%total" + format = " %used/%total" } load { - format = "%1min" + format = "%1min" } memory { - format = "%used/%available" - threshold_degraded = "1G" - format_degraded = "MEMORY < %available" + format = "%used/%available" + threshold_degraded = "1G" + format_degraded = "MEMORY < %available" } cpu_usage { @@ -65,5 +68,18 @@ cpu_temperature 0 { } tztime local { - format = " %Y-%m-%d  %H:%M:%S" + format = " %Y-%m-%d  %H:%M:%S" +} + +volume master { + format = " %volume" # шаблон громкости в активном состоянии + format_muted = " %volume" # шаблон громкости в состоянии muted (без звука) + device = "default" + mixer = "Master" + mixer_idx = 0 +} + + +tztime holder__headphones { + format = "holder__headphones" } From cd31360232eb51e9df4c1914a8f240aad26d6e39 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 23 Jan 2023 19:56:20 +0300 Subject: [PATCH 42/76] rename functions nvim lua --- README.md | 2 ++ sub/nvim/lua/base/keys/run-scripts.lua | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 210e1ee..3a248e3 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ Config files for: * git * ranger * i3 +* vim +* neovim ### Prompt diff --git a/sub/nvim/lua/base/keys/run-scripts.lua b/sub/nvim/lua/base/keys/run-scripts.lua index dbb4bda..da93e4d 100644 --- a/sub/nvim/lua/base/keys/run-scripts.lua +++ b/sub/nvim/lua/base/keys/run-scripts.lua @@ -9,6 +9,7 @@ end local function set_keymap_base(key, cmd) local map = vim.keymap.set + local opts = { noremap = true, silent = true } keymap_keys = string.format([[r%s]], key) map("n", keymap_keys, cmd, opts) end @@ -23,7 +24,7 @@ local function set_keymap_run_script(cmd) set_keymap_base("r", cmd_string) end -local function create_function_autocmd_filetype(set_keymap_func, ft, cmd) +local function create_function_autocmd_by_filetype(set_keymap_func, ft, cmd) return function() if vim.bo.filetype == ft then set_keymap_func(cmd) @@ -31,7 +32,7 @@ local function create_function_autocmd_filetype(set_keymap_func, ft, cmd) end end -local function create_function_autocmd_filename(set_keymap_func, fn, cmd) +local function create_function_autocmd_by_filename(set_keymap_func, fn, cmd) return function() if vim.fn.expand('%:t') == fn then set_keymap_func(cmd) @@ -39,21 +40,21 @@ local function create_function_autocmd_filename(set_keymap_func, fn, cmd) end end -local function autocmd_run_script_filetype(ft, cmd) - autocmd(create_function_autocmd_filetype(set_keymap_run_script, ft, cmd)) +local function autocmd_run_script_by_filetype(ft, cmd) + autocmd(create_function_autocmd_by_filetype(set_keymap_run_script, ft, cmd)) end local function autocmd_format_file_by_filetype(ft, cmd) - autocmd(create_function_autocmd_filetype(set_keymap_format_file, ft, cmd)) + autocmd(create_function_autocmd_by_filetype(set_keymap_format_file, ft, cmd)) end -autocmd_run_script_filetype('python', 'python3') -autocmd_run_script_filetype('go', 'go run') -autocmd_run_script_filetype('rust', 'cargo run') -autocmd_run_script_filetype('markdown', 'glow') +autocmd_run_script_by_filetype('python', 'python3') +autocmd_run_script_by_filetype('go', 'go run') +autocmd_run_script_by_filetype('rust', 'cargo run') +autocmd_run_script_by_filetype('markdown', 'glow') -autocmd(create_function_autocmd_filename(set_keymap_run_script, 'manpage', 'man -P cat -l')) +autocmd(create_function_autocmd_by_filename(set_keymap_run_script, 'manpage', 'man -P cat -l')) autocmd_format_file_by_filetype('rust', 'cargo fmt -p') autocmd_format_file_by_filetype('go', 'go fmt') From 1cb99ef623d2add575071d47cd831d924f96e9b8 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 23 Jan 2023 20:50:32 +0300 Subject: [PATCH 43/76] i3status_wrapper: add emoji of battery, rename wrapper --- Makefile | 2 +- functions/{i3status_wrapper.sh => i3status_wrapper} | 2 +- sub/i3/config | 2 +- sub/nvim/after/plugin/nvim-treesitter.lua | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) rename functions/{i3status_wrapper.sh => i3status_wrapper} (95%) diff --git a/Makefile b/Makefile index 2ad88da..37145b1 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ i3: mkdir -p ~/.config/i3status ln -s $(PWD)/sub/i3/config ~/.config/i3/config ln -s $(PWD)/sub/i3/statusconfig ~/.config/i3status/config - ln -s $(PWD)/functions/i3status_wrapper.sh ~/.local/bin/i3status_wrapper.sh + ln -s $(PWD)/functions/i3status_wrapper ~/.local/bin/i3status_wrapper bat: test -d ~/.config/bat || \ diff --git a/functions/i3status_wrapper.sh b/functions/i3status_wrapper similarity index 95% rename from functions/i3status_wrapper.sh rename to functions/i3status_wrapper index 76fb8ca..1d6c796 100755 --- a/functions/i3status_wrapper.sh +++ b/functions/i3status_wrapper @@ -39,7 +39,7 @@ function remove_holder { function headphones { - battery_status="$(bluetoothctl info 14:0A:29:0A:6A:2F | grep "Battery Percentage" | awk -F '[()]' '{ print "🎧"$2"%" }')" + battery_status="$(bluetoothctl info 14:0A:29:0A:6A:2F | grep "Battery Percentage" | awk -F '[()]' '{ print "🎧🔋"$2"%" }')" local json="{ \"full_text\": \"$battery_status\", \"color\": \"#FFFFFF\"}" diff --git a/sub/i3/config b/sub/i3/config index af9c233..3917582 100644 --- a/sub/i3/config +++ b/sub/i3/config @@ -198,7 +198,7 @@ bindsym $mod+r mode "resize" # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { - status_command exec ~/.local/bin/i3status_wrapper.sh + status_command exec ~/.local/bin/i3status_wrapper tray_output DP-0 } diff --git a/sub/nvim/after/plugin/nvim-treesitter.lua b/sub/nvim/after/plugin/nvim-treesitter.lua index 4f5eb9c..bf0c762 100644 --- a/sub/nvim/after/plugin/nvim-treesitter.lua +++ b/sub/nvim/after/plugin/nvim-treesitter.lua @@ -3,6 +3,12 @@ local status, nvim_treesitter = pcall(require, "nvim-treesitter") if (not status) then return end nvim_treesitter.setup { + ensure_installed = {"python", "lua", "vim", "html", "rust"}, + sync_install = true, auto_install = true, + + highlight = { + enable = true, + } } From dc54a413ceba5e3c315c00a1746453c5e80d5a74 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 23 Jan 2023 21:23:16 +0300 Subject: [PATCH 44/76] nvim: add plugin trouble --- sub/nvim/after/plugin/mason-lspconfig.lua | 6 ++++++ sub/nvim/after/plugin/mason.lua | 6 ++++++ sub/nvim/after/plugin/trouble.lua | 17 +++++++++++++++++ sub/nvim/lua/base/plugins.lua | 16 ++++++++++++++-- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 sub/nvim/after/plugin/mason-lspconfig.lua create mode 100644 sub/nvim/after/plugin/mason.lua create mode 100644 sub/nvim/after/plugin/trouble.lua diff --git a/sub/nvim/after/plugin/mason-lspconfig.lua b/sub/nvim/after/plugin/mason-lspconfig.lua new file mode 100644 index 0000000..43d7584 --- /dev/null +++ b/sub/nvim/after/plugin/mason-lspconfig.lua @@ -0,0 +1,6 @@ + +local status, mason_lspconfig = pcall(require, "mason-lspconfig") +if (not status) then return end + + +mason_lspconfig.setup() diff --git a/sub/nvim/after/plugin/mason.lua b/sub/nvim/after/plugin/mason.lua new file mode 100644 index 0000000..7b163f2 --- /dev/null +++ b/sub/nvim/after/plugin/mason.lua @@ -0,0 +1,6 @@ + +local status, mason = pcall(require, "mason") +if (not status) then return end + + +mason.setup() diff --git a/sub/nvim/after/plugin/trouble.lua b/sub/nvim/after/plugin/trouble.lua new file mode 100644 index 0000000..1a73863 --- /dev/null +++ b/sub/nvim/after/plugin/trouble.lua @@ -0,0 +1,17 @@ + +local status, trouble = pcall(require, "trouble") +if (not status) then return end + +trouble.setup() + + +local function set_trouble_keymap(key, cmd) + local opts = {silent = true, noremap = true} + vim.keymap.set("n", string.format("x%s", key), cmd, opts) +end + +set_trouble_keymap("x", "TroubleToggle") +set_trouble_keymap("w", "TroubleToggle workspace_diagnostics") +set_trouble_keymap("d", "TroubleToggle document_diagnostics") +set_trouble_keymap("l", "TroubleToggle loclist") +set_trouble_keymap("q", "TroubleToggle quickfix") diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 1852c79..6cbeb29 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -1,9 +1,12 @@ +vim.cmd([[packadd packer.nvim]]) + + return require('packer').startup(function(use) use 'wbthomason/packer.nvim' use { 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true } + requires = { 'kyazdani42/nvim-web-devicons' } } use 'ellisonleao/gruvbox.nvim' @@ -32,12 +35,21 @@ return require('packer').startup(function(use) config = function() require('Comment').setup() end } - -- pyright + use { 'folke/trouble.nvim', + requires = { 'kyazdani42/nvim-web-devicons' } + } + use 'neovim/nvim-lspconfig' use 'hrsh7th/nvim-cmp' use 'hrsh7th/cmp-nvim-lsp' use 'saadparwaiz1/cmp_luasnip' use 'L3MON4D3/LuaSnip' + use { + 'williamboman/mason.nvim', + requires = { + "williamboman/mason-lspconfig.nvim" + }, + } use { 'nvim-telescope/telescope.nvim', From cdbf41230d20a8c746383077168ae320d5a402f9 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 23 Jan 2023 21:44:09 +0300 Subject: [PATCH 45/76] nvim : to --- sub/nvim/lua/base/keys/keys.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index a1bf8c8..960b2da 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -44,17 +44,17 @@ map("n", '', vim.cmd.tabprev, opts) -- Kill current buffer -map("n", 'qq', ':bd!', opts) +map("n", 'qq', 'bd!', opts) -- Quick exit without saving -map("n", 'qa', ':qa!', opts) +map("n", 'qa', 'qa!', opts) -map("n", 'eh', ':set list!', opts) +map("n", 'eh', 'set list!', opts) vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]] -- Tags panel (ctags required) -map("n", 't', ':TagbarToggle', opts) +map("n", 't', 'TagbarToggle', opts) -- Telescope From cb848505ba2dabbaa64341857ef9eb5c109a7122 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 23 Jan 2023 21:54:06 +0300 Subject: [PATCH 46/76] nvim keys for gitsigns --- sub/nvim/after/plugin/trouble.lua | 12 ------------ sub/nvim/lua/base/keys/keys.lua | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/sub/nvim/after/plugin/trouble.lua b/sub/nvim/after/plugin/trouble.lua index 1a73863..825ab10 100644 --- a/sub/nvim/after/plugin/trouble.lua +++ b/sub/nvim/after/plugin/trouble.lua @@ -3,15 +3,3 @@ local status, trouble = pcall(require, "trouble") if (not status) then return end trouble.setup() - - -local function set_trouble_keymap(key, cmd) - local opts = {silent = true, noremap = true} - vim.keymap.set("n", string.format("x%s", key), cmd, opts) -end - -set_trouble_keymap("x", "TroubleToggle") -set_trouble_keymap("w", "TroubleToggle workspace_diagnostics") -set_trouble_keymap("d", "TroubleToggle document_diagnostics") -set_trouble_keymap("l", "TroubleToggle loclist") -set_trouble_keymap("q", "TroubleToggle quickfix") diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index 960b2da..2ea9027 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -95,3 +95,24 @@ end -- Toggle line number style map('n', 'l', create_function_tabdo('lua toggle_number_style()'), opts) + + + +local function set_trouble_keymap(key, cmd) + map("n", string.format("x%s", key), string.format("TroubleToggle %s", cmd), opts) +end + +set_trouble_keymap("x", "") +set_trouble_keymap("w", "workspace_diagnostics") +set_trouble_keymap("d", "document_diagnostics") +set_trouble_keymap("l", "loclist") +set_trouble_keymap("q", "quickfix") + + +local function set_gitsigns_keymap(key, cmd) + map("n", string.format("g%s", key), string.format("Gitsigns %s", cmd), opts) +end + +set_gitsigns_keymap('p', 'preview_hunk') +set_gitsigns_keymap('b', 'blame_line') +set_gitsigns_keymap('n', 'next_hunk') From 641e247c34814a58f712f43ab834069c51bf5699 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 23 Jan 2023 22:40:30 +0300 Subject: [PATCH 47/76] nvim lsp --- Makefile | 2 +- sub/nvim/after/plugin/lspconfig.lua | 2 +- sub/nvim/lua/base/keys/run-scripts.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 37145b1..42a76f0 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ alacritty: ln -s $(PWD)/sub/alacritty/alacritty.yml ~/.config/alacritty/ nvim: - @echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'; npm install -g pyright" + @echo "sudo pacman -S npm ctags fzf glow; mkdir ~/.npm-global; npm config set prefix '~/.npm-global'" ln -s $(PWD)/sub/nvim ~/.config/nvim ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim diff --git a/sub/nvim/after/plugin/lspconfig.lua b/sub/nvim/after/plugin/lspconfig.lua index baa7c33..3373ebb 100644 --- a/sub/nvim/after/plugin/lspconfig.lua +++ b/sub/nvim/after/plugin/lspconfig.lua @@ -39,7 +39,7 @@ end -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches -local servers = { 'pyright' } +local servers = { 'pyright', 'sumneko_lua', 'rust_analyzer' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach, diff --git a/sub/nvim/lua/base/keys/run-scripts.lua b/sub/nvim/lua/base/keys/run-scripts.lua index da93e4d..d3282d0 100644 --- a/sub/nvim/lua/base/keys/run-scripts.lua +++ b/sub/nvim/lua/base/keys/run-scripts.lua @@ -10,7 +10,7 @@ end local function set_keymap_base(key, cmd) local map = vim.keymap.set local opts = { noremap = true, silent = true } - keymap_keys = string.format([[r%s]], key) + local keymap_keys = string.format([[r%s]], key) map("n", keymap_keys, cmd, opts) end From 89d517fe40092e2906ae139d439908010329fbe2 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 24 Jan 2023 13:02:31 +0300 Subject: [PATCH 48/76] change depricated which to command -v --- sub/bash/aliases | 2 +- sub/bash/functions | 2 +- sub/bash/prompt | 2 +- sub/nvim/lua/base/keys/keys.lua | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sub/bash/aliases b/sub/bash/aliases index a611347..8c32716 100644 --- a/sub/bash/aliases +++ b/sub/bash/aliases @@ -1,7 +1,7 @@ # colors -if [ -x "$(which dircolors)" ]; then +if [ -x "$(command -v dircolors)" ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias grep='grep --color=auto' diff --git a/sub/bash/functions b/sub/bash/functions index a87fa00..770bd3b 100644 --- a/sub/bash/functions +++ b/sub/bash/functions @@ -152,7 +152,7 @@ docker_ips() { py() { - if [ -z "$@" -a -n "$(which ipython)" ]; then + if [ -z "$@" -a -x "$(command -v ipython)" ]; then ipython -i -c "q = exit" else python3 $@ diff --git a/sub/bash/prompt b/sub/bash/prompt index 0b1e3fb..f043ca6 100644 --- a/sub/bash/prompt +++ b/sub/bash/prompt @@ -1,7 +1,7 @@ parse_git_branch() { - if ! [ -x "$(which git)" ]; then + if ! [ -x "$(command -v git)" ]; then return fi diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index 2ea9027..77c3454 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -67,7 +67,7 @@ map("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true} -- Save from root -vim.api.nvim_create_user_command('Sw', [[execute 'silent! write !SUDO_ASKPASS=$(which vim_askpass_helper) sudo -A tee % >/dev/null']], {}) +vim.api.nvim_create_user_command('Sw', [[execute 'silent! write !SUDO_ASKPASS=$(command -v vim_askpass_helper) sudo -A tee % >/dev/null']], {}) From c0b8785aa14ec0cf501cd34c96dfa0528aebfc8c Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 24 Jan 2023 13:32:41 +0300 Subject: [PATCH 49/76] nvim(keymaps): gitsigns and trouble plugins keymaps commentaries --- sub/nvim/lua/base/keys/keys.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index 77c3454..3357359 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -103,16 +103,14 @@ local function set_trouble_keymap(key, cmd) end set_trouble_keymap("x", "") -set_trouble_keymap("w", "workspace_diagnostics") -set_trouble_keymap("d", "document_diagnostics") -set_trouble_keymap("l", "loclist") -set_trouble_keymap("q", "quickfix") +set_trouble_keymap("w", "workspace_diagnostics") -- lsp diagnostic of workspace +set_trouble_keymap("d", "document_diagnostics") -- diagnostic of current file local function set_gitsigns_keymap(key, cmd) map("n", string.format("g%s", key), string.format("Gitsigns %s", cmd), opts) end -set_gitsigns_keymap('p', 'preview_hunk') -set_gitsigns_keymap('b', 'blame_line') -set_gitsigns_keymap('n', 'next_hunk') +set_gitsigns_keymap('p', 'preview_hunk') -- show diff +set_gitsigns_keymap('b', 'blame_line') -- show author, hash, date and message of current line commit +set_gitsigns_keymap('n', 'next_hunk') -- go to next unstaged changes From 97feb474889d7f2fee99c9eb22f37149cb053329 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 24 Jan 2023 20:14:55 +0300 Subject: [PATCH 50/76] nvim keymap Space and Enter for add blank line before and after cursorline --- sub/nvim/lua/base/keys/keys.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index 3357359..b227f1b 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -23,6 +23,8 @@ map('n', '/', map('i', 'jk', '', opts) map('i', 'ол', '', opts) +map('n', '', 'o', opts) +map('n', '', 'O', opts) -- x to blackhole map('n', 'x', '"_x', opts) From 5390b9a761c13dae458599eb51c71de95501a227 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 24 Jan 2023 21:27:14 +0300 Subject: [PATCH 51/76] feat(nvim) text-object i/ --- sub/nvim/lua/base/options.lua | 1 + sub/nvim/lua/base/plugins.lua | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sub/nvim/lua/base/options.lua b/sub/nvim/lua/base/options.lua index 0a4e985..468fdea 100644 --- a/sub/nvim/lua/base/options.lua +++ b/sub/nvim/lua/base/options.lua @@ -45,6 +45,7 @@ opt.visualbell = false opt.showcmd = true opt.showtabline = 2 +opt.ignorecase = true opt.smartcase = true -- if search line hasn`t Upper case chars - ignore case search, else case-sensivity search opt.incsearch = true diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 6cbeb29..3fc09d3 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -5,8 +5,13 @@ return require('packer').startup(function(use) use 'wbthomason/packer.nvim' use { - 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons' } + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons' } + } + + use { + 'kana/vim-textobj-lastpat', -- text-object i/, operate under finding + requires = { 'kana/vim-textobj-user' } } use 'ellisonleao/gruvbox.nvim' @@ -55,7 +60,7 @@ return require('packer').startup(function(use) 'nvim-telescope/telescope.nvim', requires = { { 'nvim-lua/plenary.nvim' }, - { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', opt = false } + { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } } } end) From af126bb2c8ce9b69eefad10ccf274d1ad206fa14 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 25 Jan 2023 00:02:15 +0300 Subject: [PATCH 52/76] feat(zsh): completion for nvim with modified files --- Makefile | 1 + sub/zsh/completion | 3 ++- sub/zsh/zfunc/_nvim | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 sub/zsh/zfunc/_nvim diff --git a/Makefile b/Makefile index 42a76f0..eb088af 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ zsh: test -d ~/.subzsh || \ ln -s $(PWD)/sub/zsh ~/.subzsh ln -s ~/.subzsh/zshrc ~/.zshrc + ln -s ~/.subzsh/zfunc ~/.zfunc mkdir ~/.subzsh/plugins git clone https://github.com/zsh-users/zsh-autosuggestions ~/.subzsh/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.subzsh/plugins/zsh-syntax-highlighting diff --git a/sub/zsh/completion b/sub/zsh/completion index ae3c014..80a5938 100644 --- a/sub/zsh/completion +++ b/sub/zsh/completion @@ -1,8 +1,9 @@ # enable completion features -fpath+=~/.zfunc +fpath=(~/.zfunc $fpath) autoload -Uz compinit compinit -d ~/.cache/zcompdump +compdef _nvim nvim zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' completer _expand _complete _correct _approximate diff --git a/sub/zsh/zfunc/_nvim b/sub/zsh/zfunc/_nvim new file mode 100644 index 0000000..8b1dd52 --- /dev/null +++ b/sub/zsh/zfunc/_nvim @@ -0,0 +1,16 @@ +#compdef nvim +#autoload + + +_nvim() { + subcmds=($(git diff --name-only 2>/dev/null)) + if [[ -z "$subcmds" ]]; then + _files + else + _values -C 'modified files' $subcmds + _files + fi + +} + +_nvim From 1245825900a3f1fb62a81a82bbc03f1ab72e3e87 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 25 Jan 2023 16:33:21 +0300 Subject: [PATCH 53/76] gitignore zwc --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 408ac6d..af29904 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ sub/vim/tmp/ sub/nvim/plugin sub/nvim/tmp/ + +*.zwc From 701ea23649a47b6318c8f56b91e66cbc03c2526e Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sat, 28 Jan 2023 23:58:30 +0300 Subject: [PATCH 54/76] edit(nvim): change directory of nvim temp files --- Makefile | 2 +- sub/nvim/lua/base/options.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index eb088af..622f43e 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ nvim: ln -s $(PWD)/sub/nvim ~/.config/nvim ln -s $(PWD)/functions/vim_askpass_helper ~/.local/bin git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim - nvim +PackerCompile +PackerClean +PackerUpdate +PackerUpdate +qall + nvim +PackerCompile +PackerSync +PackerSync ssh: cat $(PWD)/sub/ssh/config >> ~/.ssh/config diff --git a/sub/nvim/lua/base/options.lua b/sub/nvim/lua/base/options.lua index 468fdea..837d1fd 100644 --- a/sub/nvim/lua/base/options.lua +++ b/sub/nvim/lua/base/options.lua @@ -65,11 +65,11 @@ opt.undofile = true opt.history = 1000 opt.undoreload = 1000 -local prefix = vim.fn.expand("~/.cache/nvim/tmp") +local prefix = vim.fn.expand("~/.local/state/nvim") opt.undodir = { prefix .. "/undo//" } opt.backupdir = { prefix .. "/backup//" } -opt.directory = { prefix .. "/swp//" } +opt.directory = { prefix .. "/swap//" } local function makeDirIfNoExists(path) From 0368fde089b41350a9bd572ef38dc45d88fd27ac Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 29 Jan 2023 00:01:15 +0300 Subject: [PATCH 55/76] typo(readme) --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3a248e3..100f912 100644 --- a/README.md +++ b/README.md @@ -76,12 +76,11 @@ echo "Hello $USER!" | ,l | Line number styles | | ,c | Highlight cursor line | | ,/ | Toggle search highlight | -| ,qq | Delete current buffer +| ,qq | Delete current buffer | | ,qa | Close all without saving | | ,t | Tagbar | | ,rr | Run script in new tab (python, go, preview markdown)| -| ,rm | Run script (make run) | -| ,rf | Format file (go) | +| ,rf | Format file (go, rust) | From 6bac42053133357bb7db6e69b63789689c2a6f31 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 29 Jan 2023 13:33:04 +0300 Subject: [PATCH 56/76] fix(nvim): rainbow plugin not starts --- sub/nvim/after/plugin/rainbow.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sub/nvim/after/plugin/rainbow.lua b/sub/nvim/after/plugin/rainbow.lua index 0994efc..404e55e 100644 --- a/sub/nvim/after/plugin/rainbow.lua +++ b/sub/nvim/after/plugin/rainbow.lua @@ -1,12 +1,8 @@ -if (packer_plugins["vim-rainbow"] and packer_plugins["vim-rainbow"].loaded) then +if not (packer_plugins["vim-rainbow"] and packer_plugins["vim-rainbow"].loaded) then return end -vim.api.nvim_exec([[ - let g:rainbow_active = 1 -]], true) - -vim.api.nvim_create_autocmd('FileType', +vim.api.nvim_create_autocmd('BufEnter', { pattern = {"*"}, command = 'RainbowToggle' From 6eabcecc5c53c9a099ab79c08779d6307ec945fe Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 29 Jan 2023 14:26:05 +0300 Subject: [PATCH 57/76] edit(git): alias hist add colors --- sub/git/gitconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub/git/gitconfig b/sub/git/gitconfig index d7a4696..c4d8501 100644 --- a/sub/git/gitconfig +++ b/sub/git/gitconfig @@ -35,7 +35,7 @@ bm = branch --merged bn = branch --no-merged df = "!git hist | peco | awk '{print $2}' | xargs -I {} git diff {}^ {}" - hist = log --pretty=format:\"%Cgreen%h %Creset%cd %Cblue[%cn] %Creset%s%C(yellow)%d%C(reset)\" --graph --date=relative --decorate --all + hist = log --pretty=format:\"%Cgreen%h %Creset%cd %Cblue[%cn] %Creset%s%C(yellow)%d%C(reset)\" --graph --date=relative --decorate --all --color=always llog = log --graph --name-status --pretty=format:\"%C(red)%h %C(reset)(%cd) %C(green)%an %Creset%s %C(yellow)%d%Creset\" --date=relative open = "!hub browse" type = cat-file -t From 772650400066be2b38803f5273f7f55a2f9caa25 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 29 Jan 2023 16:47:44 +0300 Subject: [PATCH 58/76] feat(gitconfig): alias hs fix(gitconfig): alias edit-unmerged call with $EDITOR --- sub/git/gitconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sub/git/gitconfig b/sub/git/gitconfig index c4d8501..d804346 100644 --- a/sub/git/gitconfig +++ b/sub/git/gitconfig @@ -26,7 +26,6 @@ d = "!git diff --color=always | less -R" co = checkout ci = commit - ca = commit -a ps = "!git push origin $(git rev-parse --abbrev-ref HEAD)" pl = "!git pull origin $(git rev-parse --abbrev-ref HEAD)" st = status @@ -34,8 +33,9 @@ ba = branch -a bm = branch --merged bn = branch --no-merged - df = "!git hist | peco | awk '{print $2}' | xargs -I {} git diff {}^ {}" hist = log --pretty=format:\"%Cgreen%h %Creset%cd %Cblue[%cn] %Creset%s%C(yellow)%d%C(reset)\" --graph --date=relative --decorate --all --color=always + df = "!git hist | peco | awk '{print $2}' | xargs -I {} git diff {}^ {}" + hs = "!git hist | head" llog = log --graph --name-status --pretty=format:\"%C(red)%h %C(reset)(%cd) %C(green)%an %Creset%s %C(yellow)%d%Creset\" --date=relative open = "!hub browse" type = cat-file -t @@ -45,10 +45,8 @@ last = log -1 HEAD branches = branch -avv --list - - # edit conflicted file on merge - edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; vim `f`" + edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; $EDITOR `f`" # add conflicted file on merge add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`" From 6bd8ef9e5d9a8a66c977f15cad84f6410ad50bb1 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 29 Jan 2023 18:08:20 +0300 Subject: [PATCH 59/76] fix(i3): add keymaps to switch parent/child --- sub/i3/config | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sub/i3/config b/sub/i3/config index 3917582..4ebd832 100644 --- a/sub/i3/config +++ b/sub/i3/config @@ -98,11 +98,6 @@ bindsym $mod+Shift+Down move down bindsym $mod+Shift+Up move up bindsym $mod+Shift+Right move right -# split in horizontal orientation -# bindsym $mod+h split h - -# split in vertical orientation -bindsym $mod+v split v # enter fullscreen mode for the focused container bindsym $mod+f fullscreen toggle @@ -120,9 +115,13 @@ bindsym $mod+slash focus mode_toggle # focus the parent container bindsym $mod+a focus parent - # focus the child container -#bindsym $mod+d focus child +bindsym $mod+z focus child + +# split in horizontal orientation +bindsym $mod+b split h +# split in vertical orientation +bindsym $mod+v split v # Define names for default workspaces for which we configure key bindings later on. # We use variables to avoid repeating the names in multiple places. From 73edbd8ae46d1917e9676b02730fe3ccfcb2930c Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 30 Jan 2023 00:26:18 +0300 Subject: [PATCH 60/76] add(vim_askpass_helper_python) --- functions/vim_askpass_helper_python | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 functions/vim_askpass_helper_python diff --git a/functions/vim_askpass_helper_python b/functions/vim_askpass_helper_python new file mode 100755 index 0000000..82c853c --- /dev/null +++ b/functions/vim_askpass_helper_python @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +import os +import tkinter as tk +from tkinter import Entry, Label + + +class App: + def __init__(self): + self.root = tk.Tk() + self.root.title("vim") + self.root.attributes('-type', 'dialog') + + self.create_label() + self.create_widget_get_password() + self.create_button_ok() + + def mainloop(self): + self.root.mainloop() + + def __event_get(self, _): + print(self.widget.get()) + self.root.quit() + + def create_label(self): + label_text = f"[sudo] password for {os.getlogin()}:" + user_password = Label(self.root, text = label_text) + user_password.grid(row = 1, column = 1) + + def create_widget_get_password(self): + self.widget = Entry(self.root, show="*", width=15) + self.widget.grid(row = 1, column = 2) + self.widget.focus_set() + + def create_button_ok(self): + btn = tk.Button(self.root, text="OK") + btn.bind("", self.__event_get) + self.root.bind("", self.__event_get) + btn.grid(row = 1, column = 3) + + +if __name__ == "__main__": + app = App() + app.mainloop() From d19839a8946e271a64fc10bd9833d9e05f763470 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 30 Jan 2023 00:41:45 +0300 Subject: [PATCH 61/76] feat(nvim) run script by shebang on keymap ',rs' --- README.md | 1 + sub/nvim/lua/base/keys/run-scripts.lua | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 100f912..9a2b772 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ echo "Hello $USER!" | ,qa | Close all without saving | | ,t | Tagbar | | ,rr | Run script in new tab (python, go, preview markdown)| +| ,rs | Run script in new tab by shebang | | ,rf | Format file (go, rust) | diff --git a/sub/nvim/lua/base/keys/run-scripts.lua b/sub/nvim/lua/base/keys/run-scripts.lua index d3282d0..9a40569 100644 --- a/sub/nvim/lua/base/keys/run-scripts.lua +++ b/sub/nvim/lua/base/keys/run-scripts.lua @@ -19,9 +19,18 @@ local function set_keymap_format_file(cmd) set_keymap_base("f", cmd_string) end +local function set_keymap_run_script_base(key, cmd) + local run_script_string = [[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]] + local cmd_string = string.format(run_script_string, cmd) + set_keymap_base(key, cmd_string) +end + local function set_keymap_run_script(cmd) - local cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd) - set_keymap_base("r", cmd_string) + set_keymap_run_script_base("r", cmd) +end + +local function set_keymap_run_script_by_shebang(cmd) + set_keymap_run_script_base("s", cmd) end local function create_function_autocmd_by_filetype(set_keymap_func, ft, cmd) @@ -58,3 +67,5 @@ autocmd(create_function_autocmd_by_filename(set_keymap_run_script, 'manpage', 'm autocmd_format_file_by_filetype('rust', 'cargo fmt -p') autocmd_format_file_by_filetype('go', 'go fmt') + +autocmd(function() set_keymap_run_script_by_shebang([[$(head -1 % | cut -c 3-) %]]) end) From 4f0a5c12240b4cfd2714ccecd7241b7a4ee4e368 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 30 Jan 2023 03:37:07 +0300 Subject: [PATCH 62/76] feat(nvim): snippets --- sub/nvim/after/plugin/cmp.lua | 18 +++++++++++++++--- sub/nvim/after/plugin/luasnip.lua | 15 +++++++++++++++ sub/nvim/lua/base/plugins.lua | 6 +++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/sub/nvim/after/plugin/cmp.lua b/sub/nvim/after/plugin/cmp.lua index 3393733..e9157f4 100644 --- a/sub/nvim/after/plugin/cmp.lua +++ b/sub/nvim/after/plugin/cmp.lua @@ -3,6 +3,11 @@ local status, cmp = pcall(require, "cmp") if (not status) then return end +local function has_words_before() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + -- nvim-cmp setup local cmp = require 'cmp' cmp.setup { @@ -15,11 +20,18 @@ cmp.setup { end, }, mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), [''] = cmp.mapping.close(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, diff --git a/sub/nvim/after/plugin/luasnip.lua b/sub/nvim/after/plugin/luasnip.lua index 52761f1..984923a 100644 --- a/sub/nvim/after/plugin/luasnip.lua +++ b/sub/nvim/after/plugin/luasnip.lua @@ -2,3 +2,18 @@ local status, luasnip = pcall(require, "luasnip") if (not status) then return end +luasnip.add_snippets(nil, { + all = { + luasnip.snippet({ + trig = "ifmain", + namr = "ifmain", + dscr = "If python file run as main (not import)", + }, { + luasnip.text_node({ + "if __name__ == '__main__':", + "\t" + }) + }) + } +}) + diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 3fc09d3..19e4622 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -48,7 +48,11 @@ return require('packer').startup(function(use) use 'hrsh7th/nvim-cmp' use 'hrsh7th/cmp-nvim-lsp' use 'saadparwaiz1/cmp_luasnip' - use 'L3MON4D3/LuaSnip' + use { + 'L3MON4D3/LuaSnip', + after = 'nvim-cmp', + } + use { 'williamboman/mason.nvim', requires = { From 76130d6a5d26035b370d2f348417c0b1261e498e Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 30 Jan 2023 13:29:41 +0300 Subject: [PATCH 63/76] nvim(rm emmet plugin) --- sub/nvim/lua/base/plugins.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 19e4622..c268abc 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -24,7 +24,6 @@ return require('packer').startup(function(use) use 'preservim/vimux' use 'rbgrouleff/bclose.vim' use 'frazrepo/vim-rainbow' - use 'mattn/emmet-vim' use 'Pocco81/auto-save.nvim' use 'windwp/nvim-autopairs' use 'lewis6991/gitsigns.nvim' From fd4461570758b7c1bae9ee350852b0bbf98bfa81 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 30 Jan 2023 15:06:12 +0300 Subject: [PATCH 64/76] add(nvim snippets) --- sub/nvim/after/plugin/luasnip.lua | 19 ++++--------------- sub/nvim/lua/base/plugins.lua | 3 +-- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/sub/nvim/after/plugin/luasnip.lua b/sub/nvim/after/plugin/luasnip.lua index 984923a..36bd21d 100644 --- a/sub/nvim/after/plugin/luasnip.lua +++ b/sub/nvim/after/plugin/luasnip.lua @@ -1,19 +1,8 @@ -local status, luasnip = pcall(require, "luasnip") +local status, _ = pcall(require, "luasnip") if (not status) then return end -luasnip.add_snippets(nil, { - all = { - luasnip.snippet({ - trig = "ifmain", - namr = "ifmain", - dscr = "If python file run as main (not import)", - }, { - luasnip.text_node({ - "if __name__ == '__main__':", - "\t" - }) - }) - } -}) +local status_loader, luasnip_loaders = pcall(require, "luasnip.loaders.from_snipmate") +if (not status_loader) then return end +luasnip_loaders.lazy_load() diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index c268abc..f59ff0e 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -1,6 +1,4 @@ vim.cmd([[packadd packer.nvim]]) - - return require('packer').startup(function(use) use 'wbthomason/packer.nvim' @@ -51,6 +49,7 @@ return require('packer').startup(function(use) 'L3MON4D3/LuaSnip', after = 'nvim-cmp', } + use 'honza/vim-snippets' use { 'williamboman/mason.nvim', From a7d2f297b5d5af68eca102f9fecdec50cd0269d7 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 30 Jan 2023 19:21:51 +0300 Subject: [PATCH 65/76] nvim(snip keymaps) --- sub/nvim/after/plugin/luasnip.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sub/nvim/after/plugin/luasnip.lua b/sub/nvim/after/plugin/luasnip.lua index 36bd21d..69ff49b 100644 --- a/sub/nvim/after/plugin/luasnip.lua +++ b/sub/nvim/after/plugin/luasnip.lua @@ -1,7 +1,26 @@ -local status, _ = pcall(require, "luasnip") +local status, ls = pcall(require, "luasnip") if (not status) then return end + +vim.g.snips_author = 'thek4n' +vim.g.snips_email = 'thek4n@yandex.com' +vim.g.snips_github = 'https://github.com/thek4n' + + +local map = vim.keymap.set + +local function jump(val) + return function() + ls.jump(val) + end +end + + +map({'i', 's'}, '', jump(1)) +map({'i', 's'}, '', jump(-1)) + + local status_loader, luasnip_loaders = pcall(require, "luasnip.loaders.from_snipmate") if (not status_loader) then return end From 01b7c37139a83647957c26b7349fdfd2ad7e68d1 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 31 Jan 2023 00:27:56 +0300 Subject: [PATCH 66/76] nvim plugins description --- sub/bash/functions | 2 +- sub/nvim/lua/base/plugins.lua | 17 ++++++++++------- sub/zsh/completion | 1 + sub/zsh/zfunc/_mcd | 9 +++++++++ 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 sub/zsh/zfunc/_mcd diff --git a/sub/bash/functions b/sub/bash/functions index 770bd3b..0d80551 100644 --- a/sub/bash/functions +++ b/sub/bash/functions @@ -152,7 +152,7 @@ docker_ips() { py() { - if [ -z "$@" -a -x "$(command -v ipython)" ]; then + if [[ -z "$@" && -x "$(command -v ipython 2>/dev/null)" ]]; then ipython -i -c "q = exit" else python3 $@ diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index f59ff0e..42588f7 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -12,19 +12,19 @@ return require('packer').startup(function(use) requires = { 'kana/vim-textobj-user' } } - use 'ellisonleao/gruvbox.nvim' + use 'ellisonleao/gruvbox.nvim' -- theme use 'tpope/vim-surround' use 'tpope/vim-repeat' use 'google/vim-searchindex' - use 'tpope/vim-commentary' - use 'ap/vim-css-color' + use 'tpope/vim-commentary' -- gcc to comment line + use 'ap/vim-css-color' -- highlight hex use 'preservim/tagbar' use 'preservim/vimux' use 'rbgrouleff/bclose.vim' - use 'frazrepo/vim-rainbow' - use 'Pocco81/auto-save.nvim' - use 'windwp/nvim-autopairs' - use 'lewis6991/gitsigns.nvim' + use 'frazrepo/vim-rainbow' -- rainbow brackets + use 'Pocco81/auto-save.nvim' -- autosave files + use 'windwp/nvim-autopairs' -- auto pair brackets and tags + use 'lewis6991/gitsigns.nvim' -- git integration use 'windwp/nvim-ts-autotag' use 'lervag/vimtex' use { @@ -44,6 +44,8 @@ return require('packer').startup(function(use) use 'neovim/nvim-lspconfig' use 'hrsh7th/nvim-cmp' use 'hrsh7th/cmp-nvim-lsp' + + -- snippets use 'saadparwaiz1/cmp_luasnip' use { 'L3MON4D3/LuaSnip', @@ -51,6 +53,7 @@ return require('packer').startup(function(use) } use 'honza/vim-snippets' + -- lsp servers installer use { 'williamboman/mason.nvim', requires = { diff --git a/sub/zsh/completion b/sub/zsh/completion index 80a5938..e5a0a9c 100644 --- a/sub/zsh/completion +++ b/sub/zsh/completion @@ -4,6 +4,7 @@ fpath=(~/.zfunc $fpath) autoload -Uz compinit compinit -d ~/.cache/zcompdump compdef _nvim nvim +compdef _mcd mcd zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' completer _expand _complete _correct _approximate diff --git a/sub/zsh/zfunc/_mcd b/sub/zsh/zfunc/_mcd new file mode 100644 index 0000000..3d4b1c3 --- /dev/null +++ b/sub/zsh/zfunc/_mcd @@ -0,0 +1,9 @@ +#compdef mcd +#autoload + + +_mcd() { + _files +} + +_mcd From 96a738f6bc60b730ebcf8f3f645930e7a4c679a2 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 31 Jan 2023 01:10:55 +0300 Subject: [PATCH 67/76] fix(nvim completion): relative path to edited files + hide nvim startup message --- sub/nvim/after/plugin/colorscheme.lua | 2 +- sub/nvim/lua/base/options.lua | 5 +++++ sub/zsh/zfunc/_nvim | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sub/nvim/after/plugin/colorscheme.lua b/sub/nvim/after/plugin/colorscheme.lua index 0a0f807..d06496e 100644 --- a/sub/nvim/after/plugin/colorscheme.lua +++ b/sub/nvim/after/plugin/colorscheme.lua @@ -1,5 +1,5 @@ -local status, autosave = pcall(require, "gruvbox") +local status, _ = pcall(require, "gruvbox") if (not status) then return end vim.cmd.colorscheme("gruvbox") diff --git a/sub/nvim/lua/base/options.lua b/sub/nvim/lua/base/options.lua index 837d1fd..337aeb9 100644 --- a/sub/nvim/lua/base/options.lua +++ b/sub/nvim/lua/base/options.lua @@ -1,5 +1,6 @@ local opt = vim.opt + opt.ruler = true opt.encoding = 'utf-8' opt.fileencoding = 'utf-8' @@ -7,7 +8,11 @@ opt.fileencoding = 'utf-8' opt.number = true opt.relativenumber = true + opt.clipboard:append { 'unnamedplus' } + +opt.shm = opt.shm["_value"] .. "I" -- disable startup message + opt.shell = 'bash' opt.ttimeoutlen = 0 diff --git a/sub/zsh/zfunc/_nvim b/sub/zsh/zfunc/_nvim index 8b1dd52..58d124b 100644 --- a/sub/zsh/zfunc/_nvim +++ b/sub/zsh/zfunc/_nvim @@ -3,7 +3,7 @@ _nvim() { - subcmds=($(git diff --name-only 2>/dev/null)) + subcmds=($(git diff --name-only --relative 2>/dev/null)) if [[ -z "$subcmds" ]]; then _files else From da8d90e7ee57afbe926e35b1979d62d5b631f89a Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 31 Jan 2023 14:44:20 +0300 Subject: [PATCH 68/76] fix mcd completion --- sub/zsh/completion | 2 +- sub/zsh/zfunc/_mcd | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 sub/zsh/zfunc/_mcd diff --git a/sub/zsh/completion b/sub/zsh/completion index e5a0a9c..ff3dd2c 100644 --- a/sub/zsh/completion +++ b/sub/zsh/completion @@ -4,7 +4,7 @@ fpath=(~/.zfunc $fpath) autoload -Uz compinit compinit -d ~/.cache/zcompdump compdef _nvim nvim -compdef _mcd mcd +compdef _files mcd zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' completer _expand _complete _correct _approximate diff --git a/sub/zsh/zfunc/_mcd b/sub/zsh/zfunc/_mcd deleted file mode 100644 index 3d4b1c3..0000000 --- a/sub/zsh/zfunc/_mcd +++ /dev/null @@ -1,9 +0,0 @@ -#compdef mcd -#autoload - - -_mcd() { - _files -} - -_mcd From 41a18d9805c86f9b5ab963004475a73db466b9ff Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 31 Jan 2023 20:04:12 +0300 Subject: [PATCH 69/76] feat(nvim): gf map --- sub/nvim/lua/base/keys/keys.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index b227f1b..5bc3f09 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -45,6 +45,10 @@ map("n", '', vim.cmd.tabnext, opts) map("n", '', vim.cmd.tabprev, opts) +-- Open file under cursor in new tab +map("n", 'gf', 'gf') + + -- Kill current buffer map("n", 'qq', 'bd!', opts) -- Quick exit without saving From ccb6aa6a8dde6ba54151a2a54fcde1817ee577de Mon Sep 17 00:00:00 2001 From: TheK4n Date: Tue, 31 Jan 2023 23:33:06 +0300 Subject: [PATCH 70/76] mv zlogin to zprofile --- light/zlogin | 1 - light/zprofile | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) delete mode 100644 light/zlogin create mode 100644 light/zprofile diff --git a/light/zlogin b/light/zlogin deleted file mode 100644 index e3c35eb..0000000 --- a/light/zlogin +++ /dev/null @@ -1 +0,0 @@ -[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx >> ~/.xlogs 2>&1 diff --git a/light/zprofile b/light/zprofile new file mode 100644 index 0000000..027fea9 --- /dev/null +++ b/light/zprofile @@ -0,0 +1,4 @@ + +if systemctl -q is-active graphical.target && [[ $(tty) = "/dev/tty1" ]] && [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then + exec startx >> ~/.xlogs 2>&1 +fi From 23ca2054ee9c908d743e8f2a8b01cec185a0c022 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 9 Feb 2023 21:50:35 +0300 Subject: [PATCH 71/76] zsh poetry completion --- light/vimrc | 4 + sub/zsh/completion | 1 + sub/zsh/zfunc/_poetry | 197 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 sub/zsh/zfunc/_poetry diff --git a/light/vimrc b/light/vimrc index 8556daf..2df909f 100644 --- a/light/vimrc +++ b/light/vimrc @@ -25,6 +25,10 @@ set smartcase set hlsearch set incsearch +let &t_SI.="\e[5 q" "SI = режим вставки +let &t_SR.="\e[3 q" "SR = режим замены +let &t_EI.="\e[1 q" "EI = нормальный режим + set mousehide set mouse=a diff --git a/sub/zsh/completion b/sub/zsh/completion index ff3dd2c..34f8856 100644 --- a/sub/zsh/completion +++ b/sub/zsh/completion @@ -5,6 +5,7 @@ autoload -Uz compinit compinit -d ~/.cache/zcompdump compdef _nvim nvim compdef _files mcd +compdef _poetry poetry zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' completer _expand _complete _correct _approximate diff --git a/sub/zsh/zfunc/_poetry b/sub/zsh/zfunc/_poetry new file mode 100644 index 0000000..773fdbb --- /dev/null +++ b/sub/zsh/zfunc/_poetry @@ -0,0 +1,197 @@ +#compdef poetry + +_poetry_1733398420f0b696_complete() +{ + local state com cur + local -a opts + local -a coms + + cur=${words[${#words[@]}]} + + # lookup for command + for word in ${words[@]:1}; do + if [[ $word != -* ]]; then + com=$word + break + fi + done + + if [[ ${cur} == --* ]]; then + state="option" + opts+=("--ansi:Force ANSI output." "--directory:The working directory for the Poetry command \(defaults to the current working directory\)." "--help:Display help for the given command. When no command is given display help for the list command." "--no-ansi:Disable ANSI output." "--no-cache:Disables Poetry source caches." "--no-interaction:Do not ask any interactive question." "--no-plugins:Disables plugins." "--quiet:Do not output any message." "--verbose:Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug." "--version:Display this application version.") + elif [[ $cur == $com ]]; then + state="command" + coms+=("about:Shows information about Poetry." "add:Adds a new dependency to pyproject.toml." "build:Builds a package, as a tarball and a wheel by default." "'cache clear':Clears a Poetry cache by name." "'cache list':List Poetry\'s caches." "check:Checks the validity of the pyproject.toml file." "config:Manages configuration settings." "'debug info':Shows debug information." "'debug resolve':Debugs dependency resolution." "'env info':Displays information about the current environment." "'env list':Lists all virtualenvs associated with the current project." "'env remove':Remove virtual environments associated with the project." "'env use':Activates or creates a new virtualenv for the current project." "export:Exports the lock file to alternative formats." "help:Displays help for a command." "init:Creates a basic pyproject.toml file in the current directory." "install:Installs the project dependencies." "list:Lists commands." "lock:Locks the project dependencies." "new:Creates a new Python project at ." "publish:Publishes a package to a remote repository." "remove:Removes a package from the project dependencies." "run:Runs a command in the appropriate environment." "search:Searches for packages on remote repositories." "'self add':Add additional packages to Poetry\'s runtime environment." "'self install':Install locked packages \(incl. addons\) required by this Poetry installation." "'self lock':Lock the Poetry installation\'s system requirements." "'self remove':Remove additional packages from Poetry\'s runtime environment." "'self show':Show packages from Poetry\'s runtime environment." "'self show plugins':Shows information about the currently installed plugins." "'self update':Updates Poetry to the latest version." "shell:Spawns a shell within the virtual environment." "show:Shows information about packages." "'source add':Add source configuration for project." "'source remove':Remove source configured for the project." "'source show':Show information about sources configured for the project." "update:Update the dependencies as according to the pyproject.toml file." "version:Shows the version of the project or bumps it when a valid bump rule is provided.") + fi + + case $state in + (command) + _describe 'command' coms + ;; + (option) + case "$com" in + + (about) + opts+=() + ;; + + (add) + opts+=("--allow-prereleases:Accept prereleases." "--dev:Add as a development dependency. \(Deprecated\)" "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--editable:Add vcs/path dependencies as editable." "--extras:Extras to activate for the dependency." "--group:The group to add the dependency to." "--lock:Do not perform operations \(only update the lockfile\)." "--optional:Add as an optional dependency." "--platform:Platforms for which the dependency must be installed." "--python:Python version for which the dependency must be installed." "--source:Name of the source to use to install the package.") + ;; + + (build) + opts+=("--format:Limit the format to either sdist or wheel.") + ;; + + ('cache clear') + opts+=("--all:Clear all entries in the cache.") + ;; + + ('cache list') + opts+=() + ;; + + (check) + opts+=() + ;; + + (config) + opts+=("--list:List configuration settings." "--local:Set/Get from the project\'s local configuration." "--unset:Unset configuration setting.") + ;; + + ('debug info') + opts+=() + ;; + + ('debug resolve') + opts+=("--extras:Extras to activate for the dependency." "--install:Show what would be installed for the current system." "--python:Python version\(s\) to use for resolution." "--tree:Display the dependency tree.") + ;; + + ('env info') + opts+=("--path:Only display the environment\'s path.") + ;; + + ('env list') + opts+=("--full-path:Output the full paths of the virtualenvs.") + ;; + + ('env remove') + opts+=("--all:Remove all managed virtual environments associated with the project.") + ;; + + ('env use') + opts+=() + ;; + + (export) + opts+=("--dev:Include development dependencies. \(Deprecated\)" "--extras:Extra sets of dependencies to include." "--format:Format to export to. Currently, only constraints.txt and requirements.txt are supported." "--only:The only dependency groups to include." "--output:The name of the output file." "--with:The optional dependency groups to include." "--with-credentials:Include credentials for extra indices." "--without:The dependency groups to ignore." "--without-hashes:Exclude hashes from the exported file." "--without-urls:Exclude source repository urls from the exported file.") + ;; + + (help) + opts+=() + ;; + + (init) + opts+=("--author:Author name of the package." "--dependency:Package to require, with an optional version constraint, e.g. requests:\^2.10.0 or requests=2.11.1." "--description:Description of the package." "--dev-dependency:Package to require for development, with an optional version constraint, e.g. requests:\^2.10.0 or requests=2.11.1." "--license:License of the package." "--name:Name of the package." "--python:Compatible Python versions.") + ;; + + (install) + opts+=("--all-extras:Install all extra dependencies." "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--extras:Extra sets of dependencies to install." "--no-dev:Do not install the development dependencies. \(Deprecated\)" "--no-root:Do not install the root package \(the current project\)." "--only:The only dependency groups to include." "--only-root:Exclude all dependencies." "--remove-untracked:Removes packages not present in the lock file. \(Deprecated\)" "--sync:Synchronize the environment with the locked packages and the specified groups." "--with:The optional dependency groups to include." "--without:The dependency groups to ignore.") + ;; + + (list) + opts+=() + ;; + + (lock) + opts+=("--check:Check that the poetry.lock file corresponds to the current version of pyproject.toml." "--no-update:Do not update locked versions, only refresh lock file.") + ;; + + (new) + opts+=("--name:Set the resulting package name." "--readme:Specify the readme file format. One of md \(default\) or rst" "--src:Use the src layout for the project.") + ;; + + (publish) + opts+=("--build:Build the package before publishing." "--cert:Certificate authority to access the repository." "--client-cert:Client certificate to access the repository." "--dry-run:Perform all actions except upload the package." "--password:The password to access the repository." "--repository:The repository to publish the package to." "--skip-existing:Ignore errors from files already existing in the repository." "--username:The username to access the repository.") + ;; + + (remove) + opts+=("--dev:Remove a package from the development dependencies. \(Deprecated\)" "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--group:The group to remove the dependency from.") + ;; + + (run) + opts+=() + ;; + + (search) + opts+=() + ;; + + ('self add') + opts+=("--allow-prereleases:Accept prereleases." "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--editable:Add vcs/path dependencies as editable." "--extras:Extras to activate for the dependency." "--source:Name of the source to use to install the package.") + ;; + + ('self install') + opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--sync:Synchronize the environment with the locked packages and the specified groups.") + ;; + + ('self lock') + opts+=("--check:Check that the poetry.lock file corresponds to the current version of pyproject.toml." "--no-update:Do not update locked versions, only refresh lock file.") + ;; + + ('self remove') + opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\).") + ;; + + ('self show') + opts+=("--addons:List only add-on packages installed." "--latest:Show the latest version." "--outdated:Show the latest version but only for packages that are outdated." "--tree:List the dependencies as a tree.") + ;; + + ('self show plugins') + opts+=() + ;; + + ('self update') + opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--preview:Allow the installation of pre-release versions.") + ;; + + (shell) + opts+=() + ;; + + (show) + opts+=("--all:Show all packages \(even those not compatible with current system\)." "--latest:Show the latest version." "--no-dev:Do not list the development dependencies. \(Deprecated\)" "--only:The only dependency groups to include." "--outdated:Show the latest version but only for packages that are outdated." "--tree:List the dependencies as a tree." "--why:When showing the full list, or a --tree for a single package, also display why it\'s included." "--with:The optional dependency groups to include." "--without:The dependency groups to ignore.") + ;; + + ('source add') + opts+=("--default:Set this source as the default \(disable PyPI\). A default source will also be the fallback source if you add other sources." "--secondary:Set this source as secondary.") + ;; + + ('source remove') + opts+=() + ;; + + ('source show') + opts+=() + ;; + + (update) + opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--lock:Do not perform operations \(only update the lockfile\)." "--no-dev:Do not update the development dependencies. \(Deprecated\)" "--only:The only dependency groups to include." "--with:The optional dependency groups to include." "--without:The dependency groups to ignore.") + ;; + + (version) + opts+=("--dry-run:Do not update pyproject.toml file" "--short:Output the version number only") + ;; + + esac + + _describe 'option' opts + ;; + *) + # fallback to file completion + _arguments '*:file:_files' + esac +} + +_poetry_1733398420f0b696_complete "$@" +compdef _poetry_1733398420f0b696_complete /home/kan/.local/bin/poetry From 6b2496f7a2c91c7c5f55ac6e68e1df7c5a452a8f Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 9 Feb 2023 21:57:35 +0300 Subject: [PATCH 72/76] nvim: comment plugin fix config --- sub/nvim/after/plugin/comment.lua | 4 ++++ sub/nvim/lua/base/plugins.lua | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 sub/nvim/after/plugin/comment.lua diff --git a/sub/nvim/after/plugin/comment.lua b/sub/nvim/after/plugin/comment.lua new file mode 100644 index 0000000..2c1ecbc --- /dev/null +++ b/sub/nvim/after/plugin/comment.lua @@ -0,0 +1,4 @@ +local status, comment = pcall(require, 'Comment') +if (not status) then return end + +comment.setup() diff --git a/sub/nvim/lua/base/plugins.lua b/sub/nvim/lua/base/plugins.lua index 42588f7..efb4b09 100644 --- a/sub/nvim/lua/base/plugins.lua +++ b/sub/nvim/lua/base/plugins.lua @@ -33,9 +33,7 @@ return require('packer').startup(function(use) } use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } - use { 'numToStr/Comment.nvim', - config = function() require('Comment').setup() end - } + use 'numToStr/Comment.nvim' use { 'folke/trouble.nvim', requires = { 'kyazdani42/nvim-web-devicons' } From e3503d30706399a7020dc95e521431a8f9b0717d Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sat, 25 Feb 2023 13:48:31 +0300 Subject: [PATCH 73/76] nvim: replace deprecated lsp, fix keymaps --- sub/nvim/after/plugin/lspconfig.lua | 2 +- sub/nvim/lua/base/keys/keys.lua | 7 ++++++- sub/nvim/lua/base/options.lua | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sub/nvim/after/plugin/lspconfig.lua b/sub/nvim/after/plugin/lspconfig.lua index 3373ebb..1d83754 100644 --- a/sub/nvim/after/plugin/lspconfig.lua +++ b/sub/nvim/after/plugin/lspconfig.lua @@ -39,7 +39,7 @@ end -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches -local servers = { 'pyright', 'sumneko_lua', 'rust_analyzer' } +local servers = { 'pyright', 'lua_ls', 'rust_analyzer' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach, diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index 5bc3f09..c5ef71e 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -27,7 +27,12 @@ map('n', '', 'o', opts) map('n', '', 'O', opts) -- x to blackhole -map('n', 'x', '"_x', opts) +map({'n', 'v'}, 'x', '"_x', opts) + + +-- Put without overwrite yanked text +map('x', 'p', 'P', opts) + -- Increment/decrement map('n', '+', '', opts) diff --git a/sub/nvim/lua/base/options.lua b/sub/nvim/lua/base/options.lua index 337aeb9..f11f36c 100644 --- a/sub/nvim/lua/base/options.lua +++ b/sub/nvim/lua/base/options.lua @@ -9,6 +9,7 @@ opt.number = true opt.relativenumber = true +opt.clipboard:append { 'unnamed' } opt.clipboard:append { 'unnamedplus' } opt.shm = opt.shm["_value"] .. "I" -- disable startup message From bad3465e656755418ec4e951ee747c2912145f96 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 26 Feb 2023 01:21:52 +0300 Subject: [PATCH 74/76] fix PATH variable --- sub/bash/export | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/sub/bash/export b/sub/bash/export index e7c63ab..7ed6ad7 100644 --- a/sub/bash/export +++ b/sub/bash/export @@ -12,25 +12,19 @@ export HISTIGNORE="&:l[lsa\.]:[bf]g:exit:q:clear:c:history:h" test -z "$BROWSER" && export BROWSER=firefox -# set PATH so it includes user's private bin if it exists -if [ -d "$HOME/bin" ] ; then - export PATH="$PATH:$HOME/bin" -fi -# set PATH so it includes user's private bin if it exists if [ -d "$HOME/.local/bin" ] ; then - export PATH="$PATH:$HOME/.local/bin" + export PATH="$HOME/.local/bin:$PATH" fi if [ -d "$HOME/.npm-global/bin" ] ; then - export PATH="$PATH:$HOME/.npm-global/bin" + export PATH="$HOME/.npm-global/bin:$PATH" fi - if [ -d "$HOME/.go" ] ; then export GOPATH="$HOME/.go" fi if [ -d "$HOME/.go/bin" ] ; then - export PATH="$PATH:$HOME/.go/bin" + export PATH="$HOME/.go/bin:$PATH" fi From a5e31ca2b4df4f17eb7e4fcafc6da3db8d785301 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Sun, 26 Feb 2023 01:27:46 +0300 Subject: [PATCH 75/76] refactor nvim lua --- light/bashrc | 3 --- sub/nvim/lua/base/keys/keys.lua | 1 - sub/nvim/lua/base/keys/run-scripts.lua | 6 +++--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/light/bashrc b/light/bashrc index 07bd37c..8875bbc 100644 --- a/light/bashrc +++ b/light/bashrc @@ -82,9 +82,6 @@ alias ve='python3 -m virtualenv venv && . venv/bin/activate' alias vd='deactivate' -# docker -alias drma='docker rm $(docker ps -a -q -f status=exited)' - # python alias pipir='python3 -m pip install -r requirements.txt' diff --git a/sub/nvim/lua/base/keys/keys.lua b/sub/nvim/lua/base/keys/keys.lua index c5ef71e..4936ed8 100644 --- a/sub/nvim/lua/base/keys/keys.lua +++ b/sub/nvim/lua/base/keys/keys.lua @@ -21,7 +21,6 @@ map('n', '/', opts) map('i', 'jk', '', opts) -map('i', 'ол', '', opts) map('n', '', 'o', opts) map('n', '', 'O', opts) diff --git a/sub/nvim/lua/base/keys/run-scripts.lua b/sub/nvim/lua/base/keys/run-scripts.lua index 9a40569..b202820 100644 --- a/sub/nvim/lua/base/keys/run-scripts.lua +++ b/sub/nvim/lua/base/keys/run-scripts.lua @@ -29,8 +29,8 @@ local function set_keymap_run_script(cmd) set_keymap_run_script_base("r", cmd) end -local function set_keymap_run_script_by_shebang(cmd) - set_keymap_run_script_base("s", cmd) +local function set_keymap_run_script_by_shebang() + set_keymap_run_script_base("s", [[$(head -1 % | cut -c 3-) %]]) end local function create_function_autocmd_by_filetype(set_keymap_func, ft, cmd) @@ -68,4 +68,4 @@ autocmd(create_function_autocmd_by_filename(set_keymap_run_script, 'manpage', 'm autocmd_format_file_by_filetype('rust', 'cargo fmt -p') autocmd_format_file_by_filetype('go', 'go fmt') -autocmd(function() set_keymap_run_script_by_shebang([[$(head -1 % | cut -c 3-) %]]) end) +autocmd(set_keymap_run_script_by_shebang) From e3b358a629fbba111aad03cf720693fef61aa550 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 27 Feb 2023 01:36:01 +0300 Subject: [PATCH 76/76] refactor function showtips --- sub/bash/functions | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sub/bash/functions b/sub/bash/functions index 0d80551..3d949b8 100644 --- a/sub/bash/functions +++ b/sub/bash/functions @@ -258,8 +258,17 @@ rmt() { done } -# shows text from ~/.inittips +# shows text from ~/.tips/* showtips() { - cat ~/.inittips 2>/dev/null + + TIPS_DIR="$HOME/.tips" + + if [ ! -d "$TIPS_DIR" ]; then + mkdir "$TIPS_DIR" 2>/dev/null + git init "$TIPS_DIR" + fi + + cat "$TIPS_DIR"/* 2>/dev/null + return 0 }