-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
206 lines (176 loc) · 7.4 KB
/
init.lua
File metadata and controls
206 lines (176 loc) · 7.4 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
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
-- Plugins
local Plug = vim.fn['plug#']
vim.call('plug#begin')
Plug('catppuccin/nvim', {as = 'catppuccin'})
Plug('junegunn/fzf', { ['do'] = vim.fn['fzf#install()'] })
Plug('junegunn/fzf.vim')
vim.call('plug#end')
vim.g.catppuccin_flavour = "frappe" -- latte, frappe, macchiato, mocha
require("catppuccin").setup({
transparent_background = true,
term_colors = false,
})
vim.cmd [[colorscheme catppuccin]]
-- Config
vim.cmd('filetype plugin indent on') -- set filetype
vim.g.mapleader = " " -- sets leader key
vim.g.netrw_banner = 0 -- gets rid of the annoying banner for netrw
vim.g.netrw_browse_split=4 -- open in prior window
vim.g.netrw_altv = 1 -- change from left splitting to right splitting
vim.g.netrw_liststyle=3 -- tree style view in netrw
--vim.cmd("let g:netrw_list_hide=netrw_gitignore#Hide()")
vim.opt.title = true -- show title
vim.cmd('set path+=**') -- search current directory recursively
vim.opt.shell = 'fish'
-- vim.opt.syntax = "ON"
vim.opt.backup = false
vim.opt.compatible = false -- turn off vi compatibility mode
vim.opt.number = true -- turn on line numbers
vim.opt.relativenumber = false -- turn on relative line numbers
vim.opt.mouse = 'a' -- enable the mouse in all modes
vim.opt.ignorecase = true -- enable case insensitive searching
vim.opt.smartcase = true -- all searches are case insensitive unless there's a capital letter
vim.opt.hlsearch = false -- disable all highlighted search results
vim.opt.incsearch = true -- enable incremental searching
vim.opt.wrap = true -- enable text wrapping
vim.opt.tabstop = 3 -- tabs 3 spaces
vim.opt.softtabstop = 3 -- set multiple spaces as tabstops so <BS> does the right thing
vim.opt.shiftwidth = 3
vim.opt.fileencoding = "utf-8" -- encoding set to utf-8
vim.opt.pumheight = 10 -- number of items in popup menu
vim.opt.showtabline = 2 -- always show the tab line
vim.opt.laststatus = 2 -- always show statusline
vim.opt.signcolumn = "auto"
vim.opt.expandtab = false -- expand tab
vim.opt.smartindent = true
vim.opt.showcmd = true
vim.opt.cmdheight = 2
vim.opt.showmode = true
vim.opt.scrolloff = 8 -- scroll page when cursor is 8 lines from top/bottom
vim.opt.sidescrolloff = 8 -- scroll page when cursor is 8 spaces from left/right
vim.opt.guifont = "monospace:h17"
vim.opt.clipboard = unnamedplus
vim.opt.completeopt= { "menuone", "noselect" }
vim.opt.grepprg = "rg --smart-case --vimgrep $*"
vim.opt.grepformat = "%f:%l:%c:%m"
vim.opt.splitbelow = true -- split go below
vim.opt.splitright = true -- vertical split to the right
vim.cmd('set wildmenu') -- enable wildmenu
-- vim.opt.termguicolors = true -- terminal gui colors
-- vim.o.termguicolors = true -- three lines to hilight number
vim.o.number = true
-- Cursor
-- vim.o.cursorline = true
-- vim.opt.guicursor = "n-v-i-c:block-Cursor"
-- vim.opt.guicursor = { 'a:ver25' }
-- vim.opt.guicursor = { 'a:hor25' }
-- vim.opt.guicursor = "n-v-i-c:block-Cursor"
-- statusline
vim.cmd "highlight StatusType guibg=#b16286 guifg=#1d2021"
vim.cmd "highlight StatusFile guibg=#fabd2f guifg=#1d2021"
vim.cmd "highlight StatusModified guibg=#1d2021 guifg=#d3869b"
vim.cmd "highlight StatusBuffer guibg=#98971a guifg=#1d2021"
vim.cmd "highlight StatusLocation guibg=#458588 guifg=#1d2021"
vim.cmd "highlight StatusPercent guibg=#1d2021 guifg=#ebdbb2"
vim.cmd "highlight StatusNorm guibg=none guifg=white"
vim.o.statusline = " "
.. "L"
.. " "
.. "%l"
.. " "
.. " %#StatusType#"
.. "["
.. "%Y"
.. "]"
.. "%#StatusFile#"
.. "["
.. "%F"
.. "]"
.. "%#StatusModified#"
.. " "
.. "%m"
.. " "
.. "%#StatusNorm#"
.. "%="
.. "%#StatusBuffer#"
.. "["
.. " "
.. "%n"
.. "]"
.. "%#StatusPercent#"
.. "["
.. "%p%%"
.. "]"
-- Functional wrapper for mapping custom keybindings
function map(mode, lhs, rhs, opts)
local options = { noremap = true }
if opts then
options = vim.tbl_extend("force", options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
-- reload config
map("n", "<leader>r", ":source ~/.config/nvim/init.lua<CR>") -- reload neovim config
-- leader files
map("n", "<leader>w", ":w<CR>") -- space+t creates new tab
-- leader fzf
map("n", "<leader>b", ":Buffers!<CR>")
map("n", "<leader>f", ":Files!<CR>")
map("n", "<leader>g", ":Rg!<CR>")
-- leader tab bindings
map("n", "<leader>t", ":tabnew<CR>") -- space+t creates new tab
map("n", "<leader>x", ":tabclose<CR>") -- space+x closes current tab
map("n", "<leader>j", ":tabprevious<CR>") -- space+j moves to previous tab
map("n", "<leader>k", ":tabnext<CR>") -- space+k moves to next tab
-- leader pane splits
map("n", "<leader>v", ":vsplit") -- space+v creates a veritcal split
map("n", "<leader>s", ":split") -- space+s creates a horizontal split
-- leader pane split navigation
map("n", "<C-h>", "<C-w>h") -- control+h switches to left split
map("n", "<C-l>", "<C-w>l") -- control+l switches to right split
map("n", "<C-j>", "<C-w>j") -- control+j switches to bottom split
map("n", "<C-k>", "<C-w>k") -- control+k switches to top split
-- leader buffer navigation
map("n", "<Tab>", ":bnext <CR>") -- Tab goes to next buffer
map("n", "<S-Tab>", ":bprevious <CR>") -- Shift+Tab goes to previous buffer
map("n", "<leader>d", ":bd! <CR>") -- Space+d deletes current buffer
map("n", "<leader>;", ":buffers <CR>") -- Space+; shows current buffers
-- adjust split sizes easier
map("n", "<C-Left>", ":vertical resize +3<CR>") -- Control+Left resizes vertical split +
map("n", "<C-Right>", ":vertical resize -3<CR>") -- Control+Right resizes vertical split -
-- Open netrw in 25% split in tree view
map("n", "<leader>e", ":25Lex<CR>") -- space+e toggles netrw tree view
-- Automatically create if, case, and function templates
-- map("n", "<leader>i", "iif [ @ ]; then <CR><CR> else <CR><CR> fi <ESC>/@ <CR>")
-- map("n", "<leader>c", "icase \"$@\" in <CR><CR> @) <CR>;; <CR><CR> esac <ESC>5kI<ESC>/@<CR>")
-- map("n", "<leader>f", "i@() {<CR><CR> } <ESC>2kI<ESC>/@<CR>")
-- Easy way to get back to normal mode from home row
map("i", "jj", "<Esc>") -- kj simulates ESC
map("i", "jk", "<Esc>") -- jk simulates ESC
-- Marks
map("n", "ma", "mA")
map("n", "mb", "mB")
map("n", "mc", "mC")
map("n", "'a", "'A")
map("n", "'b", "'B")
map("n", "'c", "'C")
-- Automatically close brackets, parethesis, and quotes
--map("i", "'", "''<left>")
--map("i", "\"", "\"\"<left>")
--map("i", "(", "()<left>")
--map("i", "[", "[]<left>")
--map("i", "{", "{}<left>")
--map("i", "{;", "{};<left><left>")
--map("i", "/*", "/**/<left><left>")
-- Automatically create if, case, and function templates in insert mode
map("i", ",i", "if [ @ ]; then <CR><CR> else <CR><CR> fi ")
map("i", ",c", "case \"$@\" in <CR><CR> @) ;; <CR><CR> esac")
map("i", ",f", "@() {<CR><CR> } ")
-- Visual Maps
map("v", "<leader>r", "\"hy:%s/<C-r>h//g<left><left>") -- Replace all instances of highlighted words
map("v", "<C-s>", ":sort<CR>") -- Sort highlighted text in visual mode with Control+S
map("v", "J", ":m '>+1<CR>gv=gv") -- Move current line down
map("v", "K", ":m '>-2<CR>gv=gv") -- Move current line up
-- automatically generate a template when a new bash script or markdown document is opened.
-- vim.cmd(':autocmd BufNewFile *.sh 0r ~/.config/nvim/skeleton.sh')
-- vim.cmd(':autocmd BufNewFile *.md 0r ~/.config/nvim/skeleton.md')