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 end
117 end
118})
119
120-- mdx files are markdown
121autocmd('BufEnter,BufNewFile,BufRead', {
122 pattern = '*.mdx',
123 callback = function()
124 vim.bo.filetype = 'markdown'
125 end
126})
127
128-- filetype.nvim
129g.do_filetype_lua = 1
130g.did_load_filetypes = 0
131
132-- disable built-in plugins
133local disabled_built_ins = {
134 'gzip',
135 'shada_plugin',
136 'tarPlugin',
137 'tar',
138 'zipPlugin',
139 'zip',
140}
141
142for i, _ in ipairs(disabled_built_ins) do
143 g['loaded_' .. disabled_built_ins[i]] = 1
144end