]> git.r.bdr.sh - rbdr/dotfiles/blame - config/nvim/init.lua
Reduce further
[rbdr/dotfiles] / config / nvim / init.lua
CommitLineData
ce349909
RBR
1-------------------------------------------------------------------------------
2-- Style
3-------------------------------------------------------------------------------
4-- Editor Style
5vim.opt.number = true -- Show number column
6vim.opt.wrap = false -- Don't wrap text
7vim.opt.list = true -- Display tabs and trailing space
8vim.opt.colorcolumn='80,150' -- Show color columns
9
10-- Color
11vim.opt.termguicolors = true
12vim.cmd.color('rbdr')
13
14-- Tab Style (Always override with editorconfig)
15vim.opt.tabstop = 2 -- 2 Spaces per tab
16vim.opt.shiftwidth = 2 -- Spaces used in Autoindent
17vim.opt.softtabstop = 2 -- Spaces used when soft tabbing
18vim.opt.expandtab = true -- Always use spaces
19
20-------------------------------------------------------------------------------
21-- Behavior
22-------------------------------------------------------------------------------
23-- Search Behavior
24vim.opt.ignorecase = true -- Ignore case when searching
25vim.opt.smartcase = true -- Unless we use both cases in search
26
27-- Autocomplete Behavior
28vim.opt.wildmode = 'list:longest,list:full' -- Autocomplete common matching string
ce349909
RBR
29
30-- Folding Behavior
31vim.opt.foldmethod = 'syntax' -- Use syntax highlight to define folds
32vim.opt.foldnestmax = 10 -- Max 10 folds
33vim.opt.foldlevelstart = 99 -- Start with all folds open
34
35-- Relative Number Behavior
36vim.api.nvim_create_autocmd({'FocusLost', 'InsertEnter'}, {
37 pattern = '*',
38 callback = function () vim.opt.relativenumber = false end,
39})
40vim.api.nvim_create_autocmd({'InsertLeave', 'CursorMoved'}, {
41 pattern = '*',
42 callback = function () vim.opt.relativenumber = true end,
43})
44
45vim.keymap.set('n', '<C-n>', function()
46 vim.opt.relativenumber = not vim.opt.relativenumber
47end)
48
49-- Move lines / blocks up and down using Ctrl + Shift
50vim.keymap.set('n', '<C-S-j>', ':m .+1<CR>==')
51vim.keymap.set('n', '<C-S-k>', ':m .-2<CR>==')
52vim.keymap.set('i', '<C-S-j>', '<Esc>:m .+1<CR>==gi')
53vim.keymap.set('i', '<C-S-k>', '<Esc>:m .-2<CR>==gi')
54vim.keymap.set('v', '<C-S-j>', ':m \'>+1<CR>gv=gv')
55vim.keymap.set('v', '<C-S-k>', ':m \'<-2<CR>gv=gv')
56
57-------------------------------------------------------------------------------
58-- File Specific Behavior
59-------------------------------------------------------------------------------
60-- Makefiles
61vim.api.nvim_create_autocmd({'FileType'}, {
62 pattern = 'make',
63 callback = function () vim.opt.expandtab = false end
64})
65
66-- SNES files
67vim.api.nvim_create_autocmd({'BufNewFile', 'BufRead'}, {
68 pattern = {'*.asm', '*.s'},
69 callback = function () vim.opt.filetype = 'snes' end
70})
71
72-------------------------------------------------------------------------------
73-- Local Overrides
74-------------------------------------------------------------------------------
75pcall(require, 'init_local')
76
77-------------------------------------------------------------------------------
78-- Plugin Specific Behavior
79-------------------------------------------------------------------------------
80-- FZF
81vim.keymap.set('', '<C-P>', ':FZF <CR>')
82vim.g.fzf_layout = { down = '40%' }
83vim.g.fzf_colors = {
84 fg = {'fg', 'Normal'},
85 bg = {'bg', 'Normal'},
86 hl = {'fg', 'Comment'},
87 ['fg+'] = {'fg', 'CursorLine', 'CursorColumn', 'Normal'},
88 ['bg+'] = {'bg', 'CursorLine', 'CursorColumn'},
89 ['hl+'] = {'fg', 'Statement'},
90 info = {'fg', 'PreProc'},
91 border = {'fg', 'Ignore'},
92 prompt = {'fg', 'Conditional'},
93 pointer = {'fg', 'Exception'},
94 marker = {'fg', 'Keyword'},
95 spinner = {'fg', 'Label'},
96 header = {'fg', 'Comment'}
97}
98
99
100-- Svelte Config
101vim.g.vim_svelte_plugin_use_typescript = true
102
103-- Limelight / Goyo config
104
105vim.g.limelight_conceal_ctermfg = 'gray'
106vim.g.limelight_conceal_guifg = 'DarkGray'
107
108vim.api.nvim_create_autocmd({'User'}, {
109 pattern = 'GoyoEnter',
9603dc4b 110 command = 'Limelight'
ce349909
RBR
111})
112vim.api.nvim_create_autocmd({'User'}, {
113 pattern = 'GoyoLeave',
9603dc4b 114 command = 'Limelight!'
ce349909 115})
9603dc4b
RBR
116
117vim.keymap.set('n', '<leader>i', ':Limelight!!<CR>==')
118vim.keymap.set('i', '<leader>i', '<Esc>:Limelight!!<CR>==gi')
119vim.keymap.set('v', '<leader>i', ':<C-u>Limelight!!<CR>gv=gv')
120vim.keymap.set('n', '<leader>g', ':Goyo<CR>==')
121vim.keymap.set('i', '<leader>g', '<Esc>:Goyo<CR>==gi')
122vim.keymap.set('v', '<leader>g', ':<C-u>Goyo<CR>gv=gv')
ce349909 123
70c7322a
RBR
124-- CoC
125vim.keymap.set('i', '<TAB>', 'pumvisible() ? "\\<C-n>" : "\\<TAB>"', {expr = true, silent = true})
126vim.keymap.set('i', '<S-TAB>', 'pumvisible() ? "\\<C-p>" : "\\<C-h>"', {expr = true, silent = true})
127vim.keymap.set('i', '<S-TAB>', 'pumvisible() ? "\\<C-p>" : "\\<C-h>"', {expr = true, silent = true})
128vim.keymap.set('i', '<C-Space>', 'coc#refresh()', {expr = true, silent = true})
129vim.keymap.set('n', 'K', ':call CocActionAsync("doHover")<CR>', {silent = true})
130
131vim.keymap.set('n', '[g', '<Plug>(coc-diagnostic-prev)', {silent = true})
132vim.keymap.set('n', ']g', '<Plug>(coc-diagnostic-next)', {silent = true})
133
134vim.keymap.set('n', 'gd', '<Plug>(coc-definition)', {silent = true})
135vim.keymap.set('n', 'gy', '<Plug>(coc-type-definition)', {silent = true})
136vim.keymap.set('n', 'gi', '<Plug>(coc-implementation)', {silent = true})
137vim.keymap.set('n', 'gr', '<Plug>(coc-references)', {silent = true})
138
ce349909
RBR
139-- Plugins
140require('plugins')