summaryrefslogtreecommitdiff
path: root/cfg/.vimrc
blob: b30e31923ec404f2b66670f3b0ad4712270b6dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
"                  _                    
"   ___ ______   _(_)_ __ ___  _ __ ___ 
"  / __|_  /\ \ / / | '_ ` _ \| '__/ __|
" | (__ / / _\ V /| | | | | | | | | (__ 
"  \___/___(_)\_/ |_|_| |_| |_|_|  \___|
"                                       
" czvimrc -- ideally do *not* use this on vim
" i added a lot of stuff that vim hates here
" since i switched to neovim like last year.
" -------------------------------------------
" von czjstmax <jstmaxlol at disroot dot org>
" -------------------------------------------

" -------- 'a ---------
" file settings
filetype plugin on
filetype indent off
set encoding=utf-8
set fileencoding=utf-8
set fileformat=unix
" config stuff
let g:editorconfig = 0
set exrc secure
" tab sets
set tabstop=4
set shiftwidth=4
set expandtab
" layout-ish stuff
set splitright splitbelow
nnoremap <C-w>n :vnew<CR>
" more commodities set
set virtualedit=block
set backspace=indent,eol,start
" i dont really do C-S anymore
" but it's here as a fallback 
" in case my muscle memory gets
" un-vimmed from idk an incident xd
nnoremap <C-S> :w<CR>
inoremap <C-S> <Esc>:w<CR>a
" because fuck C-\ C-n
" i use :term too much lol
tnoremap <A-Esc> <C-\><C-n>
syntax on

" -------- 'b ---------
" i set this while crying because vim on windows sucks so much
" kinda useless though nvim suxx so this is still useful
" relative line numbers for life
set nu rnu cursorline
" disable mouse because who fucking needs that shit HAH
set mouse=
" for firenvim
set guifont=Iosevka:h12
:command! Nobg hi Normal guibg=NONE ctermbg=NONE
" leader
let mapleader = ","

" -------- 'c ---------
command! Src source ~/.vimrc
command! Vimrc edit ~/.vimrc
" the coolest regex-es you'll see (fake as fuck)
command! RmComments %s/\s*\/\/\s*.*//
" -------- 'C ---------

"add time at the right of status bar thing
set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P\ %{strftime(\"%Y年%m月%d日\ %H時%M分%S秒\")}

" for vim-polyglot
set nocompatible

" -------- 'p ---------
" vim-plug      section
call plug#begin()

    " plugin list
    Plug 'qaptoR-nvim/chocolatier.nvim'
    Plug 'nvim-tree/nvim-web-devicons' 
    Plug 'ficcdaf/ashen.nvim'
    Plug 'llathasa-veleth/vim-brainfuck'
    Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
    Plug 'lervag/vimtex'
    Plug 'vim-denops/denops.vim'
    Plug 'vim-skk/skkeleton'
    Plug 'neoclide/coc.nvim', {'branch': 'release'}
    Plug 'windwp/nvim-autopairs'
    Plug 'zenlang/zen.vim'
    Plug 'sheerun/vim-polyglot'
    Plug 'phanviet/vim-monokai-pro'
    Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
    Plug 'nvim-neo-tree/neo-tree.nvim'
    Plug 'nvim-telescope/telescope.nvim'
    Plug 'nvim-lua/plenary.nvim'
    Plug 'nvim-tree/nvim-web-devicons'
    Plug 'MunifTanjim/nui.nvim'
    Plug 'lewis6991/gitsigns.nvim'
    Plug 'kdheepak/lazygit.nvim'
    Plug 'kylechui/nvim-surround'
    Plug 'numToStr/Comment.nvim'
    Plug 'nvim-lualine/lualine.nvim'

call plug#end()
" -------- 'P ---------

nnoremap <leader>gg :LazyGit<CR>
nnoremap <leader>e :Neotree toggle<CR>

nnoremap <leader>hp :Gitsigns preview_hunk<CR>
nnoremap <leader>hs :Gitsigns stage_hunk<CR>
nnoremap <leader>hr :Gitsigns reset_hunk<CR>

nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>

lua << EOF
    require("nvim-surround").setup({})
    require('Comment').setup()
EOF

" -------- 'k ---------
"       skkeleton
" 1) global toggle stays simple and stable
imap <C-j> <Plug>(skkeleton-toggle)
cmap <C-j> <Plug>(skkeleton-toggle)
tmap <C-j> <Plug>(skkeleton-toggle)

function! s:skkeleton_init() abort
  call add(g:skkeleton#mapped_keys, '<C-k>')

  call skkeleton#config({
        \ 'eggLikeNewline': v:true,
        \ })

  call skkeleton#register_keymap('input', "\<Space>", 'henkanFirst')

  call skkeleton#register_keymap('henkan', "\<Space>", 'henkanForward')

  call skkeleton#register_keymap('input', "\<C-k>", 'katakana')

  call skkeleton#register_kanatable('rom', {
        \ "z\<Space>": ["\u3000", ''],
        \ })
endfunction

augroup skkeleton-initialize-pre
  autocmd!
  autocmd User skkeleton-initialize-pre call s:skkeleton_init()
augroup END

" -------- 't ---------
"         theme
set background=dark
"silent! color chocolatier
"silent! color retrobox
silent! color ashen
"silent! color monokai_pro
" -------- 'T ---------

" -------- 'd ---------
" disable BIG jumps everywhere (shift+up / shift+down act like plain arrows)
map     <S-Up>   <Up>
map     <S-Down> <Down>
nmap    <S-Up>   <Up>
nmap    <S-Down> <Down>
imap    <S-Up>   <Up>
imap    <S-Down> <Down>
vmap    <S-Up>   <Up>
vmap    <S-Down> <Down>
xmap    <S-Up>   <Up>
xmap    <S-Down> <Down>
omap    <S-Up>   <Up>
omap    <S-Down> <Down>
cmap    <S-Up>   <Up>
cmap    <S-Down> <Down>

" -------- 'e ---------
augroup nasm_inc
    autocmd!
    autocmd BufRead,BufNewFile *.inc set filetype=nasm
augroup END

" genius idea i came up with
augroup fuck_ftdetect
  autocmd!
  autocmd TextChanged,InsertLeave * if &ft == '' | filetype detect | endif
augroup END

lua << EOF
require('nvim-autopairs').setup{}
EOF

" -------- 'f ---------
" === coc.nvim config ===
let g:coc_global_extensions = ['coc-clangd', 'coc-html', 'coc-tsserver', 'coc-sh', 'coc-css', 'coc-pyright', 'coc-go']
let g:coc_user_config = {'clangd.inlayHints.enable': v:false}
"
hi CocErrorSign guifg=Red
hi CocErrorVirtualText guifg=Red
hi CocErrorHighlight cterm=underline gui=undercurl guisp=Red
" use undercurl for errors
autocmd CursorHold * silent call CocActionAsync('highlight')
" show diagnostics thingy on cursor hold
"autocmd CursorHold * silent call CocActionAsync('doHover')
" <tab> triggers completion and navigates in completion menu
inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <silent><expr> <S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
" <CR> confirms completion
inoremap <silent><expr> <CR> pumvisible() ? coc#_select_confirm() : "\<CR>"
" function signature while typing
autocmd CursorHoldI * silent call CocActionAsync('showSignatureHelp')

" indentation stuff for js/ts because i guess so
autocmd FileType javascript,typescript setlocal shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType javascript,typescript setlocal indentexpr=

" -------- 'g ---------
" zen-c filetype detection (w zuhaitz)
au BufRead,BufNewFile *.zc set filetype=zen

" reborn filetype detection
" temporarily set to filetype=c
au BufRead,BufNewFile *.rn set filetype=c
au BufRead,BufNewFile *.rh set filetype=c

" -------- 'h ---------
lua << EOF
    local lualine_bg = "#212121"

    local function jp_time()
        return os.date("%Y年%m月%d日 %H時%M分%S秒")
    end

    local function mode()
        local m = vim.fn.mode()

        local map = {
            n = "n / ノーマル",
            i = "i / インサート",
            v = "v / ビジュアル",
            V = "v / ビジュアル",
            ["\22"] = "v / ビジュアル",
            c = "c / コマンド",
            R = "r / リプレイス",
            t = "t / ターミナル",
        }

        return map[m] or m
    end

    local palette = {
        "#f82323",
        "#e13b3b",
        "#c85656",
        "#a96a6a",
        "#8b7a7a",
        "#6f7a6a",
        "#5f6a6a",
        "#808080",
        "#5f6a6a",
        "#6f6a6a",
        "#8b7a7a",
        "#a96a6a",
        "#c85656",
        "#e13b3b",
    }

    local function get_color()
        local i = math.floor(vim.loop.hrtime() / 1e8) % #palette + 1
        return palette[i]
    end

    local function bg()
        return lualine_bg
    end

    local function lualine_theme()
        local bg = lualine_bg

        return {
            normal = { a = { bg = bg, fg = "#ffffff" }, b = { bg = bg, fg = "#ffffff" }, c = { bg = bg } },
            insert = { a = { bg = bg, fg = "#ffffff" }, b = { bg = bg, fg = "#ffffff" }, c = { bg = bg } },
            visual = { a = { bg = bg, fg = "#ffffff" }, b = { bg = bg, fg = "#ffffff" }, c = { bg = bg } },
            replace = { a = { bg = bg, fg = "#ffffff" }, b = { bg = bg, fg = "#ffffff" }, c = { bg = bg } },
            command = { a = { bg = bg, fg = "#ffffff" }, b = { bg = bg, fg = "#ffffff" }, c = { bg = bg } },
            inactive = { a = { bg = bg, fg = "#888888" }, b = { bg = bg, fg = "#888888" }, c = { bg = bg } },
        }
    end

    require('lualine').setup({
        options = {
            theme = lualine_theme(),
            icons_enabled = true,
            globalstatus = true,
            component_separators = { left = '//', right = '//' },
            section_separators = { left = '', right = '' },
        },

        sections = {

            lualine_a = {
                {
                    mode,
                    color = function()
                        return { fg = get_color(), bg = lualine_bg, gui = "bold" }
                    end
                }
            },

            lualine_b = {
                {
                    'branch',
                    color = function() return { bg = lualine_bg, fg = "#ffffff" } end
                },
                {
                    'diff',
                    color = function() return { bg = lualine_bg } end
                }
            },

            lualine_c = {
                {
                    'filename',
                    path = 1,
                    color = function() return { bg = lualine_bg, fg = "#ffffff" } end
                }
            },

            lualine_x = {
                {
                    'diagnostics',
                    color = function() return { bg = lualine_bg } end
                },
                {
                    'encoding',
                    color = function() return { bg = lualine_bg } end
                },
                {
                    'fileformat',
                    color = function() return { bg = lualine_bg } end
                },
            },

            lualine_y = {
                {
                    'filetype',
                    color = function() return { bg = lualine_bg, fg = "#ffffff" } end
                }
            },

            lualine_z = {
                {
                    jp_time,
                    color = function() return { bg = lualine_bg } end
                }
            },
        },
    })
EOF

lua << EOF
local toggle = true

vim.keymap.set("n", "<C-w>n", function()
  if toggle then
    vim.cmd("vnew") -- right
  else
    vim.cmd("new")  -- bottom
  end
  toggle = not toggle
end, { silent = true })
EOF