summaryrefslogtreecommitdiff
path: root/home/xyz/.local/bin/px
blob: 7d5c17d273010790759c4a0674407fefdb2ecece (plain)
1
2
3
4
5
6
7
8
9
10
#!/bin/sh
# Printf Xsel

if [ $# -eq 0 ]; then
	printf '%s' "$PWD"
else
	for dir; do
		/usr/bin/printf '%q ' "$(realpath -- "$dir")"
	done
fi | xsel -ib
id='n57' href='#n57'>57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
" if without, nvim with no file will give error because it's not defined?
let fenc_bef = 0

" https://github.com/junegunn/vim-plug
call plug#begin()
" https://github.com/junegunn/fzf.vim#commands
" seems only need junegunn/fzf.vim, no need junegunn/fzf if already installed fzf with pacman
"Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
"Plug 'junegunn/fzf.vim'
"Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
if has('nvim') && executable('firefox')
	Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
endif
" tinted-theming/base16-vim has low contrast on fold title make it unreadable, but I customized it easily
" chriskempson/base16-vim doesn't do bold/italic for markdown syntax, and not maintained
" RRethy/base16-nvim does not highlight markdown codeblocks
" tinted-theming/base16-vim and RRethy/base16-nvim seem both work, both support tree-sitter
Plug 'tinted-theming/base16-vim'
" nvim-treesitter seems support markdown highlight now, run `:TSEnable highlight`, more see vc notes
" but very slow when editing large markdown files so I sitll don't enable it, maybe related:
" https://github.com/nvim-treesitter/nvim-treesitter/issues/2206
"Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}  " We recommend updating the parsers on update
" use latest vim-markdown
Plug 'tpope/vim-markdown'
" alternatives: h-hg/fcitx.nvim, rlue/vim-barbaric, lilydjwg/fcitx.vim
if executable('fcitx5')
	Plug 'rlue/vim-barbaric'
endif
" alternatives: 'thinca/vim-ref' with 'eiiches/vim-ref-info', 'HiPhish/info.vim', 'alx741/vinfo'
Plug 'https://gitlab.com/HiPhish/info.vim.git'
" :h hexmode
" other related doc: :h hex-editing, :h 23.3, :h edit-binary
if executable('xxd')
	Plug 'fidian/hexmode'
endif
call plug#end()

" next line must put below `Plug 'glacambre/firenvim'`, else if click github issue textarea, then click elsewhere, then click textarea, textarea will not be selected (no cursor in it), not sure why
let g:firenvim_config = { 'localSettings': { '.*': { 'takeover': 'never' } } }

let g:infoprg = '/usr/bin/info'

" I use only one return for better readability
function Autocmd_set_fenc()
	" need to test &modifiable for gO
	if &modifiable && (&fileencoding != "utf-8")
		let l:fenc_bef = &fileencoding
		setlocal fileencoding=utf-8
		unsilent echom ":w to rewrite as utf-8"
		return l:fenc_bef
	else
		return &fileencoding
	endif
endfunction

" https://github.com/tinted-theming/base16-vim?tab=readme-ov-file#customization
function! s:base16_customize() abort
	" make fold title more contrast and readable, by reverting some changes from:
	" https://github.com/tinted-theming/base16-vim/pull/43/files
	" tested with base16-tomorrow-night theme
	call Base16hi("FoldColumn", g:base16_gui0C, g:base16_gui01, g:base16_cterm0C, g:base16_cterm01, "", "")
	call Base16hi("Folded", g:base16_gui03, g:base16_gui01, g:base16_cterm03, g:base16_cterm01, "", "")
endfunction

" not fully understood augroup, recommanded in :help
" https://www.youtube.com/watch?v=dBBUOO1PRIU
augroup mycmd
	autocmd!
	" disable auto line break (tc) and insert comment (cro)
	autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=t
	" auto rewrite as utf-8 if not when :w
	" if use FileType *, nvim can't recognize some file extensions, ex: .csv
	autocmd BufRead * let fenc_bef = Autocmd_set_fenc()
	" similar to filetype.vim code, use setfiletype
	" .csx seems not c# but c# script file, this works tho
	" set syntax=cs also works
	autocmd BufNewFile,BufRead *.csx setfiletype cs