git.m455.casa

dotfiles

clone url: git://git.m455.casa/dotfiles


vimrc

1 vim9script
2 filetype plugin indent on
3 syntax on
4
5 set t_md=
6 set background=dark
7 set expandtab
8 set tabstop=4
9 set shiftwidth=4
10 set tw=80
11 set nomodeline
12 set autoindent
13 set splitright
14 set splitbelow
15 set ignorecase
16 set hlsearch
17 set incsearch
18 set laststatus=2
19 set shell=bash\ -l
20
21 g:mapleader = ','
22
23 g:plugins_path = expand('$HOME/.vim/pack/plugins/start')
24
25 g:plugins = [
26 'https://github.com/junegunn/fzf',
27 'https://github.com/junegunn/fzf.vim',
28 'https://github.com/tpope/vim-commentary',
29 'https://github.com/elixir-editors/vim-elixir',
30 'https://github.com/jaawerth/fennel.vim',
31 ]
32
33 if hostname() == 'pancake'
34 g:plugins = ['file://$HOME/dev/git/projects/blep/blep.vim'] + g:plugins
35 endif
36
37
38 def PluginsRemove()
39 const original_path = getcwd()
40 chdir(g:plugins_path)
41 const plugin_directories = readdir(getcwd())
42 const plugin_directories_numbered = mapnew(plugin_directories,
43 'v:key + 1 .. ". " .. v:val')
44 const removal_prompt_with_numbered_plugins =
45 ["which plugin do you want to remove?"] + plugin_directories_numbered
46 const plugin_choice = inputlist(removal_prompt_with_numbered_plugins)
47 if plugin_choice > 0
48 && plugin_choice < len(removal_prompt_with_numbered_plugins)
49 const plugin_directory_to_remove = plugin_directories[plugin_choice - 1]
50 if input("\n\nwarning: you're about to delete "
51 .. plugin_directory_to_remove .. ".\n\n"
52 .. "are you sure you want to do this? [y/n]: ") == "y"
53 echo "\n\nremoving " .. plugin_directory_to_remove .. " ..."
54 delete(plugin_directory_to_remove, "rf")
55 echo "removed " .. plugin_directory_to_remove
56 else
57 echo "\n\ncancelled plugin deletion."
58 endif
59 else
60 echo "\n\ncancelled plugin deletion."
61 endif
62 chdir(original_path)
63 enddef
64 command PluginsRemove PluginsRemove()
65
66 def PluginsInstall()
67 const original_path = getcwd()
68 echo "creating " .. g:plugins_path .. " ..."
69 mkdir(g:plugins_path, 'p')
70 chdir(g:plugins_path)
71 for plugin in g:plugins
72 const system_output = system('git clone --depth 1 ' .. plugin)
73 if v:shell_error > 0
74 const plugin_name = fnamemodify(plugin, ":t")
75 if match(system_output, "already exists") > -1
76 echo plugin_name .. " is already installed. skipping..."
77 else
78 echo "couldn't clone" .. plugin_name
79 endif
80 else
81 echo system_output
82 endif
83 endfor
84 chdir(original_path)
85 if index(g:plugins, 'https://github.com/junegunn/fzf') >= 0
86 call fzf#install()
87 endif
88 echo "done!"
89 enddef
90 command PluginsInstall PluginsInstall()
91
92 def PluginsUpdate()
93 const original_path = getcwd()
94 chdir(g:plugins_path)
95 for plugin_dir in globpath('./', '*', 0, 1)
96 chdir(plugin_dir)
97 const system_output = system('git pull')
98 const plugin_name = fnamemodify(plugin_dir, ":t")
99 if match(system_output, "Already up to date") > -1
100 echo plugin_name .. " is already up to date. skipping..."
101 else
102 echo system_output
103 endif
104 chdir("..")
105 endfor
106 chdir(original_path)
107 echo "done!"
108 enddef
109 command PluginsUpdate PluginsUpdate()
110
111 def Repl()
112 setlocal splitright
113 setlocal splitbelow
114 const choice = input('which repl? ')
115 const buffer = term_start(&shell, {'vertical': 1})
116 term_sendkeys(buffer, choice .. "\<CR>")
117 wincmd p
118 enddef
119 command Repl Repl()
120
121 command Vterm :vertical terminal
122
123 # send selection or current line to split terminal
124 vnoremap <Leader>ee y<C-w>w<C-w>""<C-w>p
125 nnoremap <Leader>ee yy<C-w>w<C-w>""<C-w>p
126
127 # similar to clearing the terminal screen with ctrl-l
128 noremap <silent> <C-l> :nohlsearch<CR>
129
130 # this also allows me to run :only by typing <C-o>o
131 nnoremap <C-o> <C-w>
132 tnoremap <C-o> <C-w>
133
134 # comment/uncomment wrapper around commentary
135 noremap <silent> <S-Tab> :normal gcc<Esc>
136
137 # disable :W (:Windows from fzf) because i always run this damn thing by
138 # accident
139 command W :w
140
141 autocmd BufWritePre * :%s/\s\+$//e