-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinit.lua
More file actions
158 lines (141 loc) · 5.05 KB
/
init.lua
File metadata and controls
158 lines (141 loc) · 5.05 KB
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
require("config.lazy")
require("config.lsp")
vim.cmd("set tabstop=2 shiftwidth=2 softtabstop=2 expandtab")
vim.o.confirm = true
vim.o.cursorline = true
vim.o.ignorecase = true
vim.o.mouse = ""
vim.o.number = true
vim.o.smartcase = true
vim.o.scrolloff = 5
vim.o.showmatch = true
vim.o.undofile = true
vim.o.foldenable = false
vim.o.wildignore =
"*.pyc,*.o,*.class,*.lo,.git,vendor/*,node_modules/**,bower_components/**,elm-stuff/**,elm.js,*/tmp/*,*.so,*.swp,*zip"
vim.keymap.set("n", "<leader>sv", ":source %<CR>")
vim.cmd([[
autocmd FileType * autocmd BufWritePre <buffer> %s/\s\+$//e
]])
vim.cmd([[
nmap <Leader>sI :call SynStack()<CR>
" function! <SID>SynStack()
" if !exists("*synstack")
" return
" endif
" echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
" endfunc
function! SynStack()
echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"
endfunction
]])
-- ========= Normal Shortcuts ========
vim.keymap.set("n", "<leader>nh", ":nohls<CR>", { silent = true })
vim.keymap.set("i", "</", "</<C-X><C-O>")
vim.keymap.set("n", "<CR><CR>", "i<CR><esc>w")
vim.keymap.set("n", "<C-w>m", "<C-w>|<C-w>_")
vim.keymap.set("n", "<leader>p", ":set paste!<CR>")
-- " ========= Insert Shortcuts ========
vim.keymap.set("i", "<C-L>", "<SPACE>=><SPACE>")
vim.cmd("autocmd FileType elixir,elm imap <buffer> <C-L> <SPACE>-><SPACE>")
vim.keymap.set("i", "<C-X>l", "{%<SPACE><SPACE>%}<esc>hhi")
vim.keymap.set("i", "<C-X>v", "{{<SPACE><SPACE>}}<esc>hhi")
-- " ========= Visual Shortcuts ========
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
-- " ========= Commands ========
vim.cmd('command! Yankfname let @* = expand("%")')
vim.keymap.set("n", "<C-G>", ":Yankfname<CR> <C-G>")
if vim.fn.filereadable("~/.config/nvim/init.vim.local") ~= 0 then
vim.cmd("source ~/.config/nvim/init.vim.local")
end
vim.cmd([[
if (has("termguicolors"))
set termguicolors
endif
]])
vim.cmd('let g:markdown_recommended_style = 0')
function GotoAlternateFile(split_mode)
local current_file = vim.fn.expand('%')
local alt_file
if string.match(current_file, "/app/") then
alt_file = current_file:gsub("/app/", "/test/"):gsub("%.rb$", "_test.rb")
else
alt_file = current_file:gsub("/test/", "/app/"):gsub("_test%.rb$", ".rb")
end
if vim.fn.filereadable(alt_file) == 1 then
if split_mode == "vsplit" then
vim.cmd('vsplit')
vim.cmd('wincmd l')
vim.cmd('edit ' .. alt_file)
else
vim.cmd('edit ' .. alt_file)
end
else
print("No alternate file found: " .. alt_file)
end
end
vim.api.nvim_set_keymap('n', 'ga', ':lua GotoAlternateFile()<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'gA', ':lua GotoAlternateFile("vsplit")<CR>', { noremap = true, silent = true })
function UnwrapBlock()
vim.fn.search("do\\($\\| |\\)\\| {\\($\\|\\s*|\\)", "W", vim.fn.line("."))
vim.cmd("normal V%<gv")
vim.cmd("'>d|'<d")
end
vim.api.nvim_set_keymap('n', '<Leader>bu', ':lua UnwrapBlock()<CR>', {noremap = true, silent = true})
function WrapBlock()
vim.cmd("normal j")
vim.fn.search("do\\($\\| |\\)\\| {\\($\\|\\s*|\\)", "W", vim.fn.line("."))
vim.cmd("normal %oend")
vim.cmd("normal V%=")
end
vim.api.nvim_set_keymap('n', '<Leader>bw', ':lua WrapBlock()<CR>', {noremap = true, silent = true})
-- let g:rubycomplete_buffer_loading = 1
--
-- Plug '~/.config/nvim/local-plugins/color-schemes'
-- Plug 'bling/vim-airline', {'commit': '4e2546a2098954b74cbc612f573826f13d6fb88e'}
-- " Plug 'edkolev/tmuxline.vim', {'commit': '30012a964e8bd06e9b7612e2a838ef51a1993b0d'}
-- Plug 'KeitaNakamura/neodark.vim'
-- Plug 'rhysd/vim-gfm-syntax', {'commit': 'c0ff9e4994d4e79c8d5edf963094518dceea2623'}
-- Plug 'vim-airline/vim-airline-themes', {'commit': '9772475fcc24bee50c884aba20161465211520c8'}
--
-- " Plug '~/dev/neoprism.vim'
-- " Plug 'windwp/nvim-autopairs'
-- " Plug 'windwp/nvim-ts-autotag', {'branch': 'main'}
-- " Plug 'tjdevries/colorbuddy.vim'
--
-- " ========= Plugin Settings ========
--
-- " 'bling/vim-airline'
-- let g:airline_powerline_fonts = 1
-- let g:tmuxline_powerline_separators = 1
-- let g:airline#extensions#branch#vcs_checks = []
--
-- " 'edkolev/tmuxline.vim'
-- let g:tmuxline_powerline_separators = 0
--
-- " 'elmcast/elm-vim'
-- let g:elm_format_autosave = 1
--
--
-- " ========= Functions ========
--
-- command! SudoW w !sudo tee %
--
--
-- if s:has_nvim && filereadable(glob("~/.config/nvim/init.vim.local"))
-- source ~/.config/nvim/init.vim.local
-- elseif !s:has_nvim && filereadable(glob("~/.vimrc.local"))
-- source ~/.vimrc.local
-- endif
--
-- let g:airline_powerline_fonts = 1
-- let g:airline_theme='tomorrow'
-- " let g:lightline.colorscheme = 'neodark'
-- let g:tmuxline_powerline_separators = 1
--
-- " Cursorline coloring for bright environments
-- " autocmd BufEnter * highlight CursorLine ctermbg=Yellow ctermfg=Black cterm=bold
-- " autocmd BufLeave * highlight CursorLine ctermbg=Yellow ctermfg=None cterm=bold