Eric Bower
·
2025-02-17
init.lua
1local o = vim.o
2o.termguicolors = true
3o.background = 'dark'
4o.encoding = 'utf-8'
5o.fileencoding = 'utf-8'
6o.number = true
7o.tabstop = 2
8o.shiftwidth = 2
9o.softtabstop = 2
10o.expandtab = true
11o.colorcolumn = '80'
12o.laststatus = 2
13o.wrap = false
14o.cursorline = false
15o.autoread = true
16o.updatetime = 250
17o.cursorline = false
18o.backspace = 'indent,eol,start'
19o.completeopt = 'menuone,noselect'
20o.signcolumn = 'yes'
21o.shell = '/bin/bash'
22o.list = true
23
24local g = vim.g
25g.mapleader = ','
26g.maplocalleader = ','
27
28local opts = { noremap=true, silent=true }
29local set_keymap = vim.keymap.set
30set_keymap('n', '<leader>b', '<C-O>', opts)
31set_keymap('n', 'Q', '<nop>', opts)
32set_keymap('n', '<leader>w', ':!make fmt<CR>', opts)
33set_keymap('n', '<Esc>', [[<C-\><C-n>]], opts)
34
35local api = vim.api
36
37-- Taken from https://github.com/norcalli/nvim_utils
38local function nvim_create_augroups(definitions)
39 for group_name, definition in pairs(definitions) do
40 api.nvim_command('augroup '..group_name)
41 api.nvim_command('autocmd!')
42 for _, def in ipairs(definition) do
43 local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
44 api.nvim_command(command)
45 end
46 api.nvim_command('augroup END')
47 end
48end
49
50local autocmds = {
51 language_spacing = {
52 {
53 'BufRead,BufNewFile,BufEnter',
54 'make',
55 'setlocal tabstop=4 shiftwidth=4 softtabstop=4',
56 },
57 },
58 golang = {
59 {
60 'BufRead,BufNewFile,BufEnter',
61 '*.go',
62 'setlocal noexpandtab copyindent preserveindent softtabstop=0 shiftwidth=4 tabstop=4',
63 },
64 },
65 typescript = {
66 { 'BufNewFile,BufRead', '*.ts,*.mts', 'setlocal filetype=typescript' },
67 },
68 markdown = {
69 { 'BufNewFile,BufRead', '*.md,*.mdx', 'setlocal filetype=markdown' },
70 },
71 quickfix = {
72 { 'FileType', 'qf', 'setlocal wrap' }
73 },
74 wrapmdfiles = {
75 { 'FileType', 'markdown', 'setlocal wrap tw=79 formatoptions+=t tabstop=2 shiftwidth=2 softtabstop=2' },
76 },
77 wraptextfiles = {
78 { 'FileType', 'text', 'setlocal wrap tw=79 formatoptions+=t tabstop=2 shiftwidth=2 softtabstop=2' },
79 },
80}
81
82nvim_create_augroups(autocmds)
83
84require 'plugins'