diff --git a/.config/karabiner/karabiner.json b/.config/karabiner/karabiner.json index 3616c71..1de017a 100644 --- a/.config/karabiner/karabiner.json +++ b/.config/karabiner/karabiner.json @@ -266,16 +266,6 @@ "ignore": false, "manipulate_caps_lock_led": true, "simple_modifications": [ - { - "from": { - "key_code": "right_command" - }, - "to": [ - { - "key_code": "right_option" - } - ] - }, { "from": { "key_code": "non_us_backslash" @@ -285,6 +275,16 @@ "key_code": "grave_accent_and_tilde" } ] + }, + { + "from": { + "key_code": "right_command" + }, + "to": [ + { + "key_code": "right_option" + } + ] } ] }, @@ -408,6 +408,32 @@ ] } ] + }, + { + "disable_built_in_keyboard_if_exists": false, + "fn_function_keys": [], + "identifiers": { + "is_keyboard": false, + "is_pointing_device": true, + "product_id": 631, + "vendor_id": 1452 + }, + "ignore": true, + "manipulate_caps_lock_led": false, + "simple_modifications": [] + }, + { + "disable_built_in_keyboard_if_exists": false, + "fn_function_keys": [], + "identifiers": { + "is_keyboard": true, + "is_pointing_device": false, + "product_id": 0, + "vendor_id": 4152 + }, + "ignore": false, + "manipulate_caps_lock_led": true, + "simple_modifications": [] } ], "fn_function_keys": [ diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index a713c80..8e943d7 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -185,7 +185,7 @@ local handlers = { -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches -local servers = { 'pyright', 'bashls', 'ansiblels', 'gopls', 'solargraph'} +local servers = { 'pyright', 'bashls', 'ansiblels', 'gopls', 'solargraph', 'terraformls'} for _, lsp in pairs(servers) do require('lspconfig')[lsp].setup { on_attach = on_attach, @@ -322,7 +322,7 @@ autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=fals let g:neoformat_try_formatprg = 1 let g:neoformat_basic_format_trim = 1 let g:neoformat_only_msg_on_error = 1 -autocmd BufWritePre * undojoin | Neoformat +autocmd BufWritePre * silent! undojoin | Neoformat let g:neoformat_python_black = { \ 'exe': 'black', \ 'stdin': 1, @@ -407,6 +407,10 @@ set completeopt-=preview let mapleader = "\" nmap 2 :w! +" Adding print message +autocmd FileType python nmap f i print(--------DEBUG--------)print()print(--------END DEBUG--------) +autocmd FileType sh nmap f i echo -e "--------DEBUG--------"echo -e ""echo -e "--------END DEBUG--------" + " Adding commentary xmap c Commentary nmap c Commentary @@ -476,6 +480,11 @@ vnoremap f 0I nnoremap :tabprevious nnoremap :tabnext +nnoremap :tabnew +inoremap :tabpreviousi +inoremap :tabnexti +inoremap :tabnew + " Better moving nnoremap J } nnoremap K { @@ -502,7 +511,6 @@ nnoremap ee :!mupdf $(echo % \| sed 's/tex$/pdf/') & disown map :NvimTreeToggle nnoremap r :NvimTreeRefresh nnoremap n :NvimTreeFindFile -nnoremap :tabnew nnoremap :Goyo cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' edit! map :setlocal spell! spelllang=en_gb @@ -553,6 +561,10 @@ au BufNewFile,BufRead *.conf setfiletype conf autocmd BufWritePre * %s/\s\+$//e autocmd BufWritepre * %s/\n\+\%$//e +" Source: https://vi.stackexchange.com/questions/20077/automatically-highlight-all-occurrences-of-the-selected-text-in-visual-mode +" highlight the visual selection after pressing enter. +xnoremap "*y:silent! let searchTerm = '\V'.substitute(escape(@*, '\/'), "\n", '\\n', "g") let @/ = searchTerm echo '/'.@/ call histadd("search", searchTerm) set hls + """""""""""""""""""""""""""""""" " FZF """""""""""""""""""""""""""""""" diff --git a/.config/nvim/installer.sh b/.config/nvim/installer.sh index db31522..f6d63ee 100755 --- a/.config/nvim/installer.sh +++ b/.config/nvim/installer.sh @@ -1,10 +1,66 @@ #!/bin/bash -npm -g i pyright --force -npm -g i bash-language-server --force -npm -g i yaml-language-server --force -npm -g i @ansible/ansible-language-server --force -GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest -GO111MODULE=on go install golang.org/x/tools/gopls@latest -pip install black -pip3 install black +function timestamp() { + echo "[+] $(date +'%F %T') [INFO] $*" +} + +function err() { + echo "[-] $(date +'%F %T') [ERROR] $*" >&2 +} + +function command_start() { + timestamp "Command $* has been started." + if ! "$*"; then + err "Command $* went wrong." + exit + fi + timestamp "Command $* has been ended." +} + +function install_pyright() { + # Install pyright + sudo npm -g i pyright --force +} + +function install_bash-language-server() { + # Install bash-language-server + sudo npm -g i bash-language-server --force +} + +function install_yaml-language-server() { + # Install yaml-language-server + sudo npm -g i yaml-language-server --force +} + +function install_ansible-language-server() { + # Install ansible-language-server + sudo npm -g i @ansible/ansible-language-server --force +} + +function install_shfmt() { + # Install shfmt + GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest +} + +function install_gopls() { + # Install gopls + GO111MODULE=on go install golang.org/x/tools/gopls@latest +} + +function install_black() { + # Install black + pip install black + pip3 install black +} + +function main() { + command_start install_pyright + command_start install_bash-language-server + command_start install_yaml-language-server + command_start install_ansible-language-server + command_start install_shfmt + command_start install_gopls + command_start install_black +} + +main diff --git a/.local/bin/terraform-ls b/.local/bin/terraform-ls new file mode 100755 index 0000000..87e75bd Binary files /dev/null and b/.local/bin/terraform-ls differ diff --git a/.zshrc b/.zshrc index 34c2ab1..ccf0846 100644 --- a/.zshrc +++ b/.zshrc @@ -3,8 +3,13 @@ CONFIG=$HOME/.config parse_git_branch() { - command=$(git symbolic-ref --short HEAD 2> /dev/null) - [ -z $command ] && echo -e "$ " || echo -e "$(git symbolic-ref --short HEAD 2> /dev/null) $ " + command=$(git branch \ + 2> /dev/null \ + | sed -n -e 's/^\* \(.*\)/\1/p' \ + | awk 'NF{print $NF}' \ + | sed 's/)//g' \ + 2> /dev/null) + [ -z $command ] && echo -e "$ " || echo -e "$command $ " } gbranch() { @@ -42,7 +47,7 @@ FPATH=/usr/local/share/zsh/site-functions:$FPATH # If command execution time above min. time, plugins will not output time. ZSH_COMMAND_TIME_MIN_SECONDS=10 ZSH_COMMAND_TIME_MSG="Execution time: %s sec" -ZSH_COMMAND_TIME_EXCLUDE=(ranger git nvim fzf vim mcedit v ssh) +ZSH_COMMAND_TIME_EXCLUDE=(ranger git nvim fzf vim mcedit v ssh lg lazygit) export GPG_TTY=$(tty) # export TERM=xterm-256color @@ -72,7 +77,7 @@ alias emerge="sudo emerge" alias channel-check='sudo iwlist wlan0 scan | egrep -i "essid|frequency"' alias grep="grep" alias egrep="egrep" -[[ "$(uname)" == "Darwin" ]] && alias ls="ls -Gh" || alias ls="ls -h --color=auto" +alias ls="ls -h --color=auto" alias ll='ls -lha' alias cp='cp -v' alias mv='mv -v' @@ -99,21 +104,16 @@ alias gnew="git checkout -b" alias glog="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches" alias cal="cal -3" alias code="vscodium-bin" -alias vpn="sudo /root/.local/bin/protonvpn c -f" -alias vpnch="sudo /root/.local/bin/protonvpn c --cc CH" -alias vpnd="sudo /root/.local/bin/protonvpn d" alias tv="~/MEGA/tv/tv.sh" alias newswork="newsboat --url=$HOME/.config/newsboat/urlswork" alias vim="nvim -p" alias denpl="trans en:pl" alias dplen="trans pl:en" alias notes="nvim $HOME/git/notes/index.md" -alias mgr="cd $HOME/Documents/Mega-Documents/Magisterka-Marcin/Semestr1/" -[[ "$(uname)" == "Darwin" ]] && alias mpv="mpv --no-resume-playback" || alias mpv="__NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __GLX_VENDOR_LIBRARY_NAME=nvidia __GL_SYNC_TO_VBLANK=0 mpv --vo=x11 --hwdec=no --ytdl-raw-options="yes-playlist=" --no-resume-playback --ytdl-format='bestvideo[height<=?1080]+bestaudio/best'" +alias mpv="__NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __GLX_VENDOR_LIBRARY_NAME=nvidia __GL_SYNC_TO_VBLANK=0 mpv --vo=x11 --hwdec=no --ytdl-raw-options="yes-playlist=" --no-resume-playback --ytdl-format='bestvideo[height<=?1080]+bestaudio/best'" alias aria2c="aria2c --seed-time=0 --disable-ipv6 --max-upload-limit=1k" alias lg="lazygit" alias update-brew="brew upgrade --cask" -alias cl="cd $HOME/Documents/Collage/Semestr2" alias irc="ssh mikrus -t 'screen -r'" alias rsync="rsync --progress" @@ -121,7 +121,7 @@ alias rsync="rsync --progress" export PATH=$HOME/.local/bin:$PATH export PATH=/sbin:$PATH export GOPATH=$HOME/golang -export GOROOT=/usr/local/opt/go/libexec +export GOROOT=/usr/lib/go export PATH=$PATH:$GOPATH/bin export PATH=$PATH:$GOROOT/bin export PATH=$PATH:$HOME/.gem/ruby/2.6.0/bin @@ -135,18 +135,23 @@ fi # Export for Mac if [[ "$(uname)" == "Darwin" ]]; then + # Resolve problem with GOPATH + # https://stackoverflow.com/questions/66284870/go-get-not-downloading-to-src-folder + export GO111MODULE=off + + # Other export export PATH="/usr/local/opt/openssl@3/bin:$PATH" export PATH=$PATH:$HOME/Library/Python/3.9/bin + export PATH=$PATH:/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/bin export LDFLAGS="-L/usr/local/opt/openssl@3/lib" export CPPFLAGS="-I/usr/local/opt/openssl@3/include" export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig" alias lsblk="diskutil list" alias Update="brew update; brew upgrade" - - # Resolve problem with GOPATH - # https://stackoverflow.com/questions/66284870/go-get-not-downloading-to-src-folder - export GO111MODULE=off + alias ls="ls -Gh" + alias mpv="mpv --no-resume-playback" + alias code="open -a 'Visual Studio Code'" fi # Resolve problem with