aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/keymaps.vim
blob: 4bb893280efb9467a7ebc6adf80e41a07073a839 (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
scriptencoding utf-8

vnoremap <leader>p "_dP

nnoremap Y y$

nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap J mzJ`z

inoremap , ,<c-g>u
inoremap . .<c-g>u
inoremap ! !<c-g>u
inoremap ? ?<c-g>u
inoremap $ $<c-g>u
inoremap > ><c-g>u

vnoremap < <gv
vnoremap > >gv

vnoremap <leader>s :!sort<CR>

" move to use HYDRA
" nnoremap <leader>wh :wincmd h<CR>
" nnoremap <leader>wj :wincmd j<CR>
" nnoremap <leader>wk :wincmd k<CR>
" nnoremap <leader>wl :wincmd l<CR>
" nnoremap <leader>wq :wincmd q<CR>

" Make windows to be basically the same size
" nnoremap <leader>= <C-w>=

nnoremap <leader>wsv :vsp<CR>
nnoremap <leader>wsh :sp<CR>

nnoremap <leader>j :cnext<CR>
nnoremap <leader>k :cprev<CR>

nnoremap <leader>i :lnext<CR>
nnoremap <leader>o :lprev<CR>

nnoremap <leader>bd :bd!<CR>

nnoremap <expr> <leader><leader>dp ":saveas " .  expand('%')

" For moving quickly up and down,
" Goes to the first line above/below that isn't whitespace
" Thanks to: http://vi.stackexchange.com/a/213
nnoremap <silent> gj :let _=&lazyredraw<CR>:set lazyredraw<CR>/\%<C-R>=virtcol(".")<CR>v\S<CR>:nohl<CR>:let &lazyredraw=_<CR>
nnoremap <silent> gk :let _=&lazyredraw<CR>:set lazyredraw<CR>?\%<C-R>=virtcol(".")<CR>v\S<CR>:nohl<CR>:let &lazyredraw=_<CR>

" Run the last command
nnoremap <leader><leader>c :<up>


if has('nvim')
    " Make esc leave terminal mode
    tnoremap <leader><Esc> <C-\><C-n>
    tnoremap <Esc><Esc> <C-\><C-n>

    " Easy moving between the buffers
    tnoremap <A-h> <C-\><C-n><C-w>h
    tnoremap <A-j> <C-\><C-n><C-w>j
    tnoremap <A-k> <C-\><C-n><C-w>k
    tnoremap <A-l> <C-\><C-n><C-w>l

    " Try and make sure to not mangle space items
    tnoremap <S-Space> <Space>
    tnoremap <C-Space> <Space>
endif

nnoremap <leader><leader>x :call alpha#save_and_exec()<cr>

nnoremap <leader>cc :cclose<CR>
ss="kr">function() return snippet_from_nodes(nil, { c(1, { t "", snippet_from_nodes(nil, { newline "\t", d(1, visibility, {}, "private"), t " ", i(2, 'Type'), t " $", f( function (args) return args[1][1]:gsub("^%u", string.lower) end, {2}), t ",", d(3, promoted_property, {}) }), }), }) end local namespace = function () local dir = vim.fn.expand('%:h') local autoloads = vim.call('composer#query', 'autoload.psr-4') if autoloads == nil then return (dir:gsub("^%l", string.upper)) end local globalNamespace for key, value in pairs(autoloads) do if string.starts(dir, value:sub(1, -2)) then globalNamespace = key:sub(1, -2); dir = dir:sub(#key + 1) break end end dir = dir:gsub("/", "\\") return string.format("%s\\%s",globalNamespace, dir ) end local class_name = function () local filename = vim.fn.expand('%:t:r') return filename end local M = { v = fmt( [[ /** * @var {} */ {} ${}; ]], { i(1, "type"), d(2, visibility, {}, "private"), i(3, "var") }), class = fmt( [[ <?php declare(strict_types=1); namespace {}; class {} {{ {} }} ]], { f(namespace), f(class_name), i(0), }), _c = { d(1, visibility, {}, "public"), t(' function __construct('), i(2, ''), t {")", "{", "\t"}, i(0), newline "}" }, _p = { d(1, visibility, {}, "public"), t " function __construct(", d(2, promoted_property), t {"", ") {", "}"}, }, fn = { d(1, visibility, {}, "public"), t(" function "), i(2, "name"), t("("), i(3, "$arg"), t(")"), c(4, { t(""), snippet_from_nodes(nil, { t(': '), i(1, "void"), }), }), newline "{", newline "\t", i(0, ""), newline "}", }, pro = { d(1, visibility, {}, "private"), t " ", i(2, "type"), t " $", i(3), }, strict = t "declare(strict_types=1);", } return M