]> git.r.bdr.sh - rbdr/dotfiles/blame - config/nvim/init.lua
Merge branch 'main' of git.sr.ht:~rbdr/dotfiles
[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
fc82060a
RBR
57-- Navigate the location list
58vim.keymap.set('n', '<M-j>', ':lnext<CR>')
59vim.keymap.set('n', '<M-k>', ':lprev<CR>')
60vim.keymap.set('n', '<M-S-j>', ':cnext<CR>')
61vim.keymap.set('n', '<M-S-k>', ':cprev<CR>')
62
ce349909
RBR
63-------------------------------------------------------------------------------
64-- File Specific Behavior
65-------------------------------------------------------------------------------
66-- Makefiles
67vim.api.nvim_create_autocmd({'FileType'}, {
68 pattern = 'make',
69 callback = function () vim.opt.expandtab = false end
70})
71
72-- SNES files
73vim.api.nvim_create_autocmd({'BufNewFile', 'BufRead'}, {
74 pattern = {'*.asm', '*.s'},
75 callback = function () vim.opt.filetype = 'snes' end
76})
77
6cb3a2cb
RBR
78vim.api.nvim_create_autocmd({'BufNewFile', 'BufRead'}, {
79 pattern = {'.plan'},
80 callback = function () vim.opt.filetype = 'markdown' end
81})
82
ce349909
RBR
83-------------------------------------------------------------------------------
84-- Local Overrides
85-------------------------------------------------------------------------------
86pcall(require, 'init_local')
87
88-------------------------------------------------------------------------------
89-- Plugin Specific Behavior
90-------------------------------------------------------------------------------
91-- FZF
af913f93
RBR
92vim.keymap.set("n", "<c-P>",
93 "<cmd>lua require('fzf-lua').files({ fzf_opts = {} })<CR>", { silent = true })
ce349909 94
7d35a7fc
RBR
95-- Toggle Autosave
96vim.api.nvim_set_keymap('n', '<leader>n', ':ASToggle<CR>', {})
97
ce349909
RBR
98-- Svelte Config
99vim.g.vim_svelte_plugin_use_typescript = true
100
fd61b7b4 101-- Coq
2d56e8a7
RBR
102vim.g.coq_settings = {
103 auto_start = 'shut-up',
104 clients = {
105 snippets = {
106 warn = {}
107 }
108 }
109}
fd61b7b4 110
ce349909
RBR
111-- Plugins
112require('plugins')
3c6ddc92 113require('treesitter_config')
73a2d994
RBR
114require('lsp')
115require('dap_config')
cd4c8b13 116require('calendar_tools')