diff --git a/config/Screenshot from 2021-04-13 09-36-03.png b/config/Screenshot from 2021-04-13 09-36-03.png deleted file mode 100644 index d77f7b5c..00000000 Binary files a/config/Screenshot from 2021-04-13 09-36-03.png and /dev/null differ diff --git a/config/newsboat/config b/config/newsboat/config new file mode 100644 index 00000000..c5677e01 --- /dev/null +++ b/config/newsboat/config @@ -0,0 +1,49 @@ +auto-reload yes +reload-time 5 +reload-threads 4 + +# Open in mpv +macro m set browser "/usr/bin/mpv %u > /dev/null 2>&1 &"; open-in-browser ; set browser "xdg-open %u" + +# Image preview +# pipe-to "tee ~/log" + +# notification +notify-program /usr/bin/notify-send +# notify-always yes + +# pager +# pager "nvim -R -c 'set ft=mail nomod noma nolist' -c 'nnoremap q :qa! ' -" +pager "~/.local/bin/newspager" +# html-renderer /usr/bin/cat +# pager "xargs echo" + +macro l pipe-to "~/.local/bin/newspager" + +# vim keybinds +unbind-key h +unbind-key j +unbind-key k +unbind-key l + +# bind-key h quit +bind-key j down +bind-key k up +# bind-key l open + +unbind-key g +bind-key g home +unbind-key G +bind-key G end + +color background default default +color listnormal default default +color listnormal_unread default default +color listfocus black cyan +color listfocus_unread black cyan +color info default black +color article default default + +highlight article "^(Title):.*$" blue default +highlight article "https?://[^ ]+" red default +highlight article "\\[image\\ [0-9]+\\]" green default diff --git a/config/nvim/init.vim b/config/nvim/init.vim index 6303e005..ca788325 100644 --- a/config/nvim/init.vim +++ b/config/nvim/init.vim @@ -5,35 +5,45 @@ call plug#begin() " QOL Plug 'airblade/vim-rooter' Plug 'yuttie/comfortable-motion.vim' - Plug 'tpope/vim-surround' Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']} + Plug 'folke/which-key.nvim' + Plug 'kdav5758/TrueZen.nvim' + Plug 'norcalli/nvim-colorizer.lua' + " Fzf Plug 'junegunn/fzf' Plug 'junegunn/fzf.vim' -" Git plugin - " Plug 'tpope/vim-fugitive' -" GUI Stuff - Plug 'vim-airline/vim-airline' - Plug 'vim-airline/vim-airline-themes' - Plug 'uttarayan21/minimalist' " Plug 'dikiaap/minimalist' - Plug 'dracula/vim' +" Statusline + Plug 'glepnir/galaxyline.nvim' , {'branch': 'main'} +" Tpope + Plug 'tpope/vim-surround' Plug 'tpope/vim-vinegar' + Plug 'tpope/vim-repeat' + Plug 'tpope/vim-speeddating' + Plug 'tpope/vim-commentary' + Plug 'tpope/vim-fugitive' +" Rust + " Plug 'arzg/vim-rust-syntax-ext' + Plug 'rust-lang/rust.vim' Plug 'mhinz/vim-crates' + Plug 'cespare/vim-toml' +" LSP Plug 'onsails/lspkind-nvim' -" Intellisense - Plug 'neoclide/coc.nvim', {'branch': 'release'} + Plug 'folke/lsp-trouble.nvim' + Plug 'neovim/nvim-lspconfig' + Plug 'nvim-lua/completion-nvim' + " Plug 'neoclide/coc.nvim', {'branch': 'release'} + " Ctags Plug 'ludovicchabant/vim-gutentags' " Plug 'majutsushi/tagbar' -" Syntax Highlighting - Plug 'rust-lang/rust.vim' - Plug 'cespare/vim-toml' -" Devicons - " Plug 'ryanoasis/vim-devicons' " No color +" GUI + " Plug 'uttarayan21/minimalist' " Plug 'dikiaap/minimalist' + Plug 'sainnhe/sonokai' Plug 'kyazdani42/nvim-web-devicons' + Plug 'Yggdroot/indentLine' " Text Objects - Plug 'tpope/vim-commentary' Plug 'wellle/targets.vim' " Dictionary Plug 'reedes/vim-wordy' @@ -48,30 +58,91 @@ call plug#end() "# Configurations "################################################## -" Remap C-h,j,k,l -"nnoremap h -"nnoremap j -"nnoremap k -"nnoremap l +" set font +set guifont=FiraCode\ Nerd\ Font\ Mono + +" Undo +set undodir=~/.cache/nvim/nvimdid +set undofile + +set timeoutlen=300 + +" Numbers and tabs +set noshowmode +set showtabline=2 +" set number relativenumber +set autoindent +set tabstop=4 +set shiftwidth=4 +set expandtab +set signcolumn=yes +set hidden +set ignorecase +set smartcase +set termguicolors +" set foldmethod=indent +" set cmdheight=2 + +nnoremap :set number! relativenumber! +nnoremap :IndentLinesToggle -" nnoremap inoremap let mapleader = "\" + " BufferNext nnoremap q :bw -"nnoremap :bNext nnoremap nnoremap n :bnext nnoremap p :bprev " Fzf -nnoremap f :Files -nnoremap ; :Buffers -nnoremap g :Rg -nnoremap t :Tags +nnoremap f :Files +nnoremap ; :Buffers +nnoremap g :Rg +nnoremap H :Himalaya +nnoremap c "+y +nnoremap v "+p -nnoremap r :registers -" nnoremap :TagbarToggle +nnoremap r :registers +nnoremap :Tags +nnoremap z :call ZenToggle() +nnoremap o :LspTroubleToggle + +" Use and to navigate through popup menu +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" +imap (completion_smart_tab) +imap (completion_smart_s_tab) + +" Set completeopt to have a better completion experience +set completeopt=menuone,noinsert,noselect + +" Avoid showing message extra message when using completion +set shortmess+=c + +" Keymaps for lspconfig + +" nnoremap gD :lua vim.lsp.buf.declaration() +" nnoremap q, lua vim.lsp.diagnostic.set_loclist() + +nnoremap gd :lua vim.lsp.buf.definition() +nnoremap K :lua vim.lsp.buf.hover(), opts) +nnoremap gi :lua vim.lsp.buf.implementation() +nnoremap :lua vim.lsp.buf.signature_help() + +nnoremap wa :lua vim.lsp.buf.add_workspace_folder() +nnoremap wr :lua vim.lsp.buf.remove_workspace_folder() +nnoremap wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + +nnoremap D :lua vim.lsp.buf.type_definition() +nnoremap rn :lua vim.lsp.buf.rename() +nnoremap ca :lua vim.lsp.buf.code_action() +nnoremap gr :lua vim.lsp.buf.references(), opts) +nnoremap e :lua vim.lsp.diagnostic.show_line_diagnostics() +nnoremap [d :lua vim.lsp.diagnostic.goto_prev(), opts) +nnoremap ]d :lua vim.lsp.diagnostic.goto_next(), opts) + + " Vim hardmode @@ -84,9 +155,8 @@ nnoremap nnoremap nnoremap -" Undo -set undodir=~/.cache/nvim/nvimdid -set undofile +" nnoremap +" nnoremap " Disable help on F1 nnoremap @@ -98,72 +168,49 @@ let g:gutentags_generate_on_new = 1 let g:gutentags_generate_on_missing = 1 let g:gutentags_generate_on_write = 1 let g:gutentags_generate_on_empty_buffer = 0 -nnoremap -nnoremap " Markdown Preview -let g:mkdp_auto_start = 1 +" let g:mkdp_auto_start = 1 let g:mkdp_filetypes = ['markdown'] - - -" Numbers and tabs -set noshowmode -set showtabline=2 -setlocal number relativenumber -set autoindent -set tabstop=4 -set shiftwidth=4 -set expandtab -set signcolumn=yes -set hidden -set ignorecase -set smartcase -" set foldmethod=indent -"set cmdheight=2 - -nnoremap :set number! relativenumber! - +let g:indentLine_char = '▏' +let g:indentLine_concealcursor = 'inc' +let g:indentLine_conceallevel = 2 "A few more remaps -nnoremap :source ~/.config/nvim/init.vim -nnoremap m :call Mpcfzf() +nnoremap :source ~/.config/nvim/init.vim +nnoremap m :call Mpcfzf() -" Intellisense +" COC " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? "\" : "\" -inoremap coc#refresh() -nnoremap K :call show_documentation() -nnoremap l :CocCommand +" inoremap +" \ pumvisible() ? "\" : +" \ check_back_space() ? "\" : +" \ coc#refresh() +" inoremap pumvisible() ? "\" : "\" +" inoremap pumvisible() ? "\" : "\" +" inoremap coc#refresh() +" nnoremap K :call show_documentation() +" nnoremap l :CocCommand -" Clipboard -" set clipboard=unnamedplus -" let g:clipboard = { -" \'name': 'PrimaryClipboard', -" \'copy': { -" \ '+': 'xclip -selection clipboard', -" \ '*': 'xclip -selection clipboard', -" \ }, -" \'paste': { -" \ '+': 'xclip -selection clipboard -out', -" \ '*': 'xclip -selection clipboard -out', -" \ }, -" \'cache_enabled': 1, -" \} +augroup AutoSaveGroup + autocmd! + " view files are about 500 bytes + " bufleave but not bufwinleave captures closing 2nd tab + " nested is needed by bufwrite* (if triggered via other autocmd) + " BufHidden for for compatibility with `set hidden` + autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview! + autocmd BufWinEnter ?* silent! loadview +augroup end +" Comment no file types with # +autocmd BufNewFile,BufRead * if empty(&filetype) | setlocal commentstring=#\ %s | endif +" autocmd BufRead urls set commentstring=#\ %s +" set commentstring=#\ %s -augroup linenumbers - autocmd WinLeave * :setlocal nonumber norelativenumber - autocmd WinEnter * :setlocal number relativenumber -augroup END " Do not edit readonly buffers autocmd BufRead *.orig set readonly @@ -176,8 +223,6 @@ let g:netrw_fastbrowse = 0 " Toggle crates plugin on opening cargo.toml file autocmd BufRead Cargo.toml call crates#toggle() -" Lspkind-nvim -lua require'lspkind'.init() " Set python global file let g:python3_host_prog = "/usr/bin/python" @@ -185,79 +230,65 @@ let g:python3_host_prog = "/usr/bin/python" let g:asmsyntax = 'nasm' " set nodejs global prog " let g:node_host_prog = "/usr/bin/neovim-node-host" -" Themeing -" set t_Co=256 -syntax on -colorscheme minimalist -" let g:dracula_colorterm = 0 -" colorscheme dracula -highlight link Crates WarningMsg -" colorscheme nord +" Themeing +syntax on +let g:sonokai_style = "default" +let g:sonokai_transparent_background = 1 +colorscheme sonokai + +hi link Crates WarningMsg if exists('+termguicolors') let &t_8f="\[38;2;%lu;%lu;%lum" let &t_8b="\[48;2;%lu;%lu;%lum" endif -" set termguicolors - - -" Airline -let g:airline_theme='dracula' -let g:airline_powerline_fonts = 1 -let g:airline#extensions#tabline#enabled = 1 -" let g:airline_statusline_ontop = 1 - -" " Tmuxline -" let g:tmuxline_preset = { -" \'a' : '#S', -" \'b' : '#W', -" \'c' : '#H', -" \'win' : '#I #W', -" \'cwin' : '#I #W', -" \'x' : '%a', -" \'y' : '#W %R', -" \'z' : '#H'} - -" Lightline -" let g:lightline = {} -" let g:lightline.colorscheme = 'darcula' -" " let g:lightline.colorscheme = 'wombat' -" let g:lightline.active = {} -" let g:lightline.active.left = [['mode', 'paste'] ,['readonly', 'filename', 'modified']] -" let g:lightline.active.right = [['lineinfo'], ['percent'], ['fileformat', 'fileencoding', 'filetype', 'charvaluehex']] -" let g:lightline.separator = { 'left': "\ue0b8", 'right': "\ue0ba" } -" let g:lightline.subseparator = { 'left': "\ue0b9", 'right': "\ue0bb" } - -" let g:lightline.tabline = {} -" let g:lightline.tabline.left = [['buffers']] -" let g:lightline.tabline.right = [['close'], ['gitbranch']] -" let g:lightline.tabline_separator = { 'left': "\ue0bc", 'right': "\ue0be" } -" let g:lightline.tabline_subseparator = { 'left': "\ue0bd", 'right': "\ue0bf" } - -" let g:lightline.component_function = { 'song': 'CurrentSong', 'gitbranch': 'FugitiveHead' } -" let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'} -" let g:lightline.component_type = {'buffers': 'tabsel'} +let &t_Cs = "\e[4:3m" +let &t_Ce = "\e[4:0m" " Rust -" let g:rustfmt_autosave = 1 +let g:rustfmt_autosave = 1 + +nnoremap da :call AppendBreakPoint() +nnoremap dc :call ClearBreakpoints() +nnoremap dr :call DebugRun() + +function! s:AppendBreakPoint() + let s:breakpoint = "break ".expand('%').":".line('.') + call writefile([s:breakpoint], "./target/breakpoints", "a") + echom "Added breakpoint at line ".line('.') +endfunction + +function! s:ClearBreakpoints() + call delete("./target/breakpoints") + echom "Cleared breakpoints" +endfunction + +function! s:DebugRun() + execute "!cargo build" + let s:dirlist = split(getcwd(),'/') + let s:projectname = s:dirlist[len(s:dirlist)-1] + " let s:projectname = system('sed -n "s/^name Cargo.toml ') + let s:executable = getcwd()."/target/debug/".s:projectname + silent execute "!alacritty -e rust-gdb -x ./target/breakpoints ".s:executable." &" +endfunction "################################################## "# Functions "################################################## " COC.nvim -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction +" function! s:check_back_space() abort +" let col = col('.') - 1 +" return !col || getline('.')[col - 1] =~# '\s' +" endfunction -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif -endfunction +" function! s:show_documentation() +" if (index(['vim','help'], &filetype) >= 0) +" execute 'h '.expand('') +" else +" call CocAction('doHover') +" endif +" endfunction " Mpc function Mpcfzf() @@ -269,3 +300,61 @@ function CurrentSong() return s endfunction +let t:zen = 1 +let t:fullscreen = 1 +let t:tmux = 1 +function! ZenToggle() + if t:zen == 0 + hi Normal guibg=NONE ctermbg=NONE + hi NonText guibg=NONE ctermbg=NONE + TZMinimalistT + if t:tmux == 1 + silent! !tmux set -g status on + endif + if t:fullscreen == 1 + silent! !bspc node focused -f -t tiled + endif + let t:zen = 1 + else + hi Normal ctermfg=255 ctermbg=234 cterm=NONE guifg=#EEEEEE guibg=#1C1C1C gui=NONE + hi NonText ctermfg=234 ctermbg=234 cterm=NONE guifg=#1C1C1C guibg=#1C1C1C gui=NONE + TZMinimalistF + if t:tmux == 1 + silent! !tmux set -g status off + endif + if t:fullscreen == 1 + silent! !bspc node focused -f -t fullscreen + endif + let t:zen = 0 + endif +endfunction + +" ######################################## +" # LUA +" ######################################## + + +" Which key +lua << EOF +require("which-key").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below +} +-- Lspkind-nvim +require'lspkind'.init() + +-- Colorizer +require'colorizer'.setup() + +-- lsp trouble +require("trouble").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below +} +require("lsp"); +require("scripts.status-line"); +-- require("scripts.eviline"); +require("scripts.truezen"); +EOF diff --git a/config/tmux/tmux.conf b/config/tmux/tmux.conf index dc8375fa..afd126b2 100644 --- a/config/tmux/tmux.conf +++ b/config/tmux/tmux.conf @@ -18,7 +18,9 @@ run -b '~/.config/tmux/plugins/tpm/tpm' set -g default-terminal 'tmux-256color' set -ga terminal-overrides ',*256col*:Tc' -set-option -sa terminal-overrides ',alacritty:RGB' +set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' +set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' +# set-option -sa terminal-overrides ',alacritty:RGB' set-option -g focus-events on set-option -sg escape-time 10 set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.config/tmux/plugins' diff --git a/local/bin/news b/local/bin/news new file mode 100755 index 00000000..3d9ebc54 --- /dev/null +++ b/local/bin/news @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +PID=$$ +export ID=$PID +DIR=/tmp/ueberzug_$PID +export UFIFO=$DIR/ufifo +# MAX_COLUMNS=60 +IMAGE=$1 + +function cleanup { + # remove_image + stop_ueberzug + if [ -d "$DIR" ];then + rm -r $DIR + fi + exit +} + + +if [ ! -d "$DIR" ];then + mkdir $DIR +fi + +source $(ueberzug library) + +function start_ueberzug { + mkfifo $UFIFO + ImageLayer --silent <"$UFIFO" & + exec 3>"$UFIFO" +} + +function stop_ueberzug { + exec 3>&- + rm $UFIFO &> /dev/null +} + +# function set_image { +# x_size=$(tput cols) +# y_size=$(tput lines) +# MAX_COLUMNS=$(($x_size/5)) +# x=$(($x_size-$MAX_COLUMNS-5)) +# y=$(($y_size-5)) +# echo $x $y +# ImageLayer::add [identifier]="$ID" [x]="${x}" [y]="${y}" \ +# [max_width]="${MAX_COLUMNS}" \ +# [path]="$@" \ +# >"$UFIFO" +# } + +# function remove_image { +# ImageLayer::remove [identifier]="$ID" \ +# >"$UFIFO" +# } + +trap cleanup EXIT + +start_ueberzug +newsboat +cleanup diff --git a/local/bin/newspager b/local/bin/newspager new file mode 100755 index 00000000..324fbdfd --- /dev/null +++ b/local/bin/newspager @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +if [ ! -p "$UFIFO" ];then + printf 'UFIFO not set\n' + exit +fi + +# echo $ID +source $(ueberzug library) +function set_image { + x_size=$(tput cols) + y_size=$(tput lines) + MAX_COLUMNS=$(($x_size * 3 / 10 )) + # MAX_COLUMNS=100 + x=$(($x_size-$MAX_COLUMNS-5)) + y=$(($y_size/2)) + ImageLayer::add [identifier]="$ID" [x]="${x}" [y]="${y}" \ + [max_width]="${MAX_COLUMNS}" \ + [path]="$@" \ + >"$UFIFO" +} +function remove_image { + ImageLayer::remove [identifier]="$ID" \ + >"$UFIFO" +} + +IMG_URL=$(cat $@ | grep image | awk 'NR==2 {print $2}') +LINK=$(cat $@ | grep ^Link: | head -1 | cut -d: -f2-) +# echo $LINK +# non posix +# if [[ "$LINK" =~ "https://www.youtube.com/.*" ]];then + +( +if [[ "$LINK" =~ "www.youtube.com" ]];then + # extract video id. + VIDEO_ID=$(echo $LINK | cut -d= -f2) + IMG_URL="https://img.youtube.com/vi/$VIDEO_ID/hqdefault.jpg" + # youtube-dl --write-thumbnail --skip-download $LINK --output /tmp/temp &> /dev/null +fi +if [ -n "$IMG_URL" ];then + curl -o /tmp/temp $IMG_URL &>/dev/null +fi + +if [ -f "/tmp/temp" ];then + set_image /tmp/temp +fi +) & + +nvim -R -c 'set ft=mail nomod noma nolist' -c 'nnoremap q :qa! ' $@ +remove_image +if [ -f /tmp/temp ];then + rm /tmp/temp +fi