aboutsummaryrefslogtreecommitdiff
path: root/config/nvim/lua/user/mods.lua
blob: ec77173918707bb717000c66a6bff1188f2a18a2 (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
--vim.cmd([[
--  function RandomColorScheme()
--    let mycolors = split(globpath(&rtp,"**/colors/*.vim"),"\n") 
--    exe 'so ' . mycolors[localtime() % len(mycolors)]
--    unlet mycolors
--  endfunction
--  
--  call RandomColorScheme()
--  
--  :command NewColor call RandomColorScheme()
--]])

--vim.cmd([[
--  function RandomColorSchemeMyPicks()
--      let mypicks = ["pyte", "fokus", "github", "peachpuff", "morning", "simple256", "xcode", "gruvbox"]
--      let mypick = mypicks[localtime() % len(mypicks)]
--      echom mypick
--      execute 'colo' mypick
--  endfunction
--
--  command NewColor call RandomColorSchemeMyPicks()
--
--  let s:use_gui = exists('g:neovide') || has('gui_running') || (has('termguicolors') && &termguicolors)
--  if (s:use_gui)
--      call RandomColorSchemeMyPicks()
--  endif
--]])

vim.cmd([[
    let g:fzf_history_dir = '~/.local/share/fzf-history'
    map <leader>z :FZF<CR>
    map <leader>a :Files<CR>
    map <leader>l :Lines<CR>
    map <leader>L :BLines<CR>
    map <leader>B :Buffers<CR>
    map <leader>h :History:<CR>
    nnoremap <leader>g :Rg<CR>
    "nnoremap <leader>t :Tags<CR>
    nnoremap <leader>m :Marks<CR>
    " This is the default extra key bindings
    let g:fzf_action = {
                \ 'ctrl-t': 'tab split',
                \ 'ctrl-x': 'split',
                \ 'ctrl-y': 'vsplit' }
    let g:fzf_tags_command = 'ctags -R'
    " Border color
    let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } }
    let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline'
    let $FZF_DEFAULT_COMMAND="rg --files --hidden"
    " Customize fzf colors to match your color scheme
    let g:fzf_colors =
                \ { 'fg':      ['fg', 'Normal'],
                \ 'bg':      ['bg', 'Normal'],
                \ 'hl':      ['fg', 'Comment'],
                \ 'fg+':     ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
                \ 'bg+':     ['bg', 'CursorLine', 'CursorColumn'],
                \ 'hl+':     ['fg', 'Statement'],
                \ 'info':    ['fg', 'PreProc'],
                \ 'border':  ['fg', 'Ignore'],
                \ 'prompt':  ['fg', 'Conditional'],
                \ 'pointer': ['fg', 'Exception'],
                \ 'marker':  ['fg', 'Keyword'],
                \ 'spinner': ['fg', 'Label'],
                \ 'header':  ['fg', 'Comment'] }
    " Get Files
    command! -bang -nargs=? -complete=dir Files
                \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
    " Get text in files with Rg
    command! -bang -nargs=* Rg
                \ call fzf#vim#grep(
                \   'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
                \   fzf#vim#with_preview(), <bang>0)
    " Ripgrep advanced
    function! RipgrepFzf(query, fullscreen)
        let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
        let initial_command = printf(command_fmt, shellescape(a:query))
        let reload_command = printf(command_fmt, '{q}')
        let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
        call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
    endfunction
    command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
    " Git grep
    command! -bang -nargs=* GGrep
                \ call fzf#vim#grep(
                \   'git grep --line-number '.shellescape(<q-args>), 0,
                \   fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
    command! -bang FM call fzf#run(fzf#wrap({'source': 'cat ~/.fzf-marks | sed "s/.*: \(.*\)$/\1/" | sed "s#~#${HOME}#"', 'sink': 'lcd'}, <bang>0))
]])

vim.cmd([[
    " Enable mouse scrollback
    set mouse=a
    tnoremap <Esc> <C-\><C-n>
    tnoremap <c-b> <c-\><c-n>
    function! ClearTerminal()
        set scrollback=1
        let &g:scrollback=1
        echo &scrollback
        call feedkeys("\i")
        call feedkeys("clear\<CR>")
        call feedkeys("\<C-\>\<C-n>")
        call feedkeys("\i")
        sleep 100m
        let &scrollback=s:scroll_value
    endfunction
]])

vim.cmd([[
    " :Rename {newname}
    function! RenameFile()
        let old_name = expand('%')
        let new_name = input('New file name: ', expand('%'), 'file')
        if new_name != '' && new_name != old_name
            exec ':saveas ' . new_name
            exec ':silent !rm ' . old_name
            redraw!
        endif
    endfunction
    map <leader>re :call RenameFile()<cr>
]])

--vim.cmd([[
--  " Markdown Settings
--  autocmd BufNewFile,BufReadPost *.md set filetype=markdown
--  let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'sql', 'pug']
--  let g:markdown_minlines = 100
--  let g:instant_markdown_autostart = 0
--]])
--
--vim.cmd([[
--  " On The Fly Table mode
--  function! s:isAtStartOfLine(mapping)
--    let text_before_cursor = getline('.')[0 : col('.')-1]
--    let mapping_pattern = '\V' . escape(a:mapping, '\')
--    let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
--    return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
--  endfunction
--]])