config/nvim/lua/settings.lua (view raw)
1local o = vim.opt
2local autocmd = vim.api.nvim_create_autocmd
3local g = vim.g
4local cmd = vim.cmd
5
6-- global options
7o.swapfile = true
8o.dir = '/tmp'
9o.smartcase = true
10o.laststatus = 2
11o.hlsearch = true
12o.incsearch = true
13o.ignorecase = true
14o.scrolloff = 12
15o.timeoutlen = 3000
16o.ttimeoutlen = 100
17o.undodir = '~/.cache/nvim/undodir'
18o.foldenable = false
19o.conceallevel = 2
20o.mouse = 'a'
21o.wildmenu = true
22o.tabstop = 4
23o.shiftwidth = 4
24o.softtabstop = 4
25o.showmode = true
26o.cursorline = false
27o.listchars='tab:│ ,nbsp:␣,trail:·,extends:>,precedes:<'
28o.hidden = true
29o.completeopt = { 'menuone', 'noselect', 'noinsert' }
30o.formatoptions:append('c')
31o.signcolumn = 'yes:2'
32o.wildignore = [[
33.git,.hg,.svn
34*.aux,*.out,*.toc
35*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class
36*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp
37*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg
38*.mp3,*.oga,*.ogg,*.wav,*.flac
39*.eot,*.otf,*.ttf,*.woff
40*.doc,*.pdf,*.cbr,*.cbz
41*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb
42*.swp,.lock,.DS_Store,._*
43]]
44
45cmd('syntax on')
46cmd('colorscheme plain')
47autocmd('TextYankPost', {
48 pattern = '*',
49 callback = function()
50 vim.highlight.on_yank{timeout=200}
51 end,
52})
53
54o.background = 'light'
55
56-- gitgutter options
57g.gitgutter_override_sign_column_highlight = 0
58g.gitgutter_sign_added = '+'
59g.gitgutter_sign_modified = '±'
60g.gitgutter_sign_removed = '-'
61g.gitgutter_sign_removed_first_line = '^'
62g.gitgutter_sign_modified_removed = '#'
63
64-- window-local options
65o.number = false
66o.list = true
67o.wrap = false
68
69-- buffer-local options
70o.expandtab = true
71
72-- set statusline
73stl = require('statusline.line')
74o.statusline = '%!luaeval("stl.statusline()")'
75
76-- u.create_augroup({
77-- { 'BufRead,BufNewFile', '/tmp/nail-*', 'setlocal', 'ft=mail' },
78-- { 'BufRead,BufNewFile', '*s-nail-*', 'setlocal', 'ft=mail' },
79-- }, 'ftmail')
80
81-- restore cursor
82autocmd('BufReadPost', {
83 pattern = '*',
84 callback = function()
85 vim.fn.setpos(".", vim.fn.getpos("'\""))
86 end,
87})
88
89-- unknown files are 'text'
90autocmd({'BufNewFile', 'BufRead'}, {
91 pattern = '*',
92 callback = function()
93 if vim.bo.filetype == "" then
94 vim.bo.filetype = 'text'
95 end
96 end,
97})
98
99-- keymap files are dts
100autocmd({'BufEnter','BufNewFile','BufRead'}, {
101 pattern = '*.keymap',
102 callback = function()
103 vim.bo.filetype = 'dts'
104 end
105})
106
107-- vim-textobj-quote only in ~/docs/writing
108autocmd({'BufEnter','BufNewFile','BufRead'}, {
109 pattern = '*.md',
110 callback = function()
111 local cwd = vim.fn.expand('%:p')
112 if cwd:find('/home/icy/docs/writing', 1, true) == 1 then
113 vim.fn['textobj#quote#init']()
114 vim.fn['pencil#init']({wrap = 'soft'})
115 vim.keymap.set('i', '--', '—', {silent = true})
116 vim.opt.breakindent = false
117 vim.opt.shiftwidth = 4
118 vim.opt.tabstop = 4
119 end
120 end
121})
122
123-- mdx files are markdown
124autocmd({'BufEnter','BufNewFile','BufRead'}, {
125 pattern = '*.mdx',
126 callback = function()
127 vim.bo.filetype = 'markdown'
128 end
129})
130
131-- filetype.nvim
132g.do_filetype_lua = 1
133g.did_load_filetypes = 0
134
135-- disable built-in plugins
136local disabled_built_ins = {
137 'gzip',
138 'shada_plugin',
139 'tarPlugin',
140 'tar',
141 'zipPlugin',
142 'zip',
143}
144
145for i, _ in ipairs(disabled_built_ins) do
146 g['loaded_' .. disabled_built_ins[i]] = 1
147end
148
149-- tmp
150vim.g.gui_font_face = 'Noto Serif'