all repos — dotfiles @ 0a867ad2e58c21d31f0ce106ab5812a152c6b83f

my *nix dotfiles

nvim/lua/settings.lua (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
local o = vim.opt
local autocmd = vim.api.nvim_create_autocmd
local g = vim.g
local cmd = vim.cmd

-- global options
o.swapfile = true
o.dir = '/tmp'
o.smartcase = true
o.laststatus = 2
o.hlsearch = true
o.incsearch = true
o.ignorecase = true
o.scrolloff = 12
o.timeoutlen = 3000
o.ttimeoutlen = 100
o.undodir = '~/.cache/nvim/undodir'
o.foldenable = false
o.conceallevel = 2
o.mouse = 'a'
o.wildmenu = true
o.tabstop = 4
o.shiftwidth = 4
o.softtabstop = 4
o.showmode = true
o.cursorline = false
o.listchars='tab:│ ,nbsp:␣,trail:·,extends:>,precedes:<'
o.hidden = true
o.completeopt = { 'menuone', 'noselect', 'noinsert' }
o.formatoptions:append('c')
o.signcolumn = 'yes:2'
o.wildignore = [[
.git,.hg,.svn
*.aux,*.out,*.toc
*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class
*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp
*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg
*.mp3,*.oga,*.ogg,*.wav,*.flac
*.eot,*.otf,*.ttf,*.woff
*.doc,*.pdf,*.cbr,*.cbz
*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb
*.swp,.lock,.DS_Store,._*
]]

cmd('syntax on')
cmd('colorscheme plain')
autocmd('TextYankPost', {
  pattern = '*',
  callback = function()
    vim.highlight.on_yank{timeout=200}
  end,
})

o.background = 'light'
o.termguicolors = true

-- gitgutter options
g.gitgutter_override_sign_column_highlight = 0
g.gitgutter_sign_added                     = '+'
g.gitgutter_sign_modified                  = '±'
g.gitgutter_sign_removed                   = '-'
g.gitgutter_sign_removed_first_line        = '^'
g.gitgutter_sign_modified_removed          = '#'

-- window-local options
o.number = false
o.list = true
o.wrap = false

-- buffer-local options
o.expandtab = true

-- set statusline
stl = require('statusline.line')
o.statusline = '%!luaeval("stl.statusline()")'

-- u.create_augroup({
--     { 'BufRead,BufNewFile', '/tmp/nail-*', 'setlocal', 'ft=mail' },
--     { 'BufRead,BufNewFile', '*s-nail-*', 'setlocal', 'ft=mail' },
-- }, 'ftmail')

-- restore cursor
autocmd('BufReadPost', {
  pattern = '*',
  callback = function()
    vim.fn.setpos(".", vim.fn.getpos("'\""))
  end,
})

-- unknown files are 'text'
autocmd({'BufNewFile', 'BufRead'}, {
  pattern = '*',
  callback = function()
    if vim.bo.filetype == "" then
      vim.bo.filetype = 'text'
    end
  end,
})

-- keymap files are dts
autocmd({'BufEnter','BufNewFile','BufRead'}, {
  pattern = '*.keymap',
  callback = function()
    vim.bo.filetype = 'dts'
  end
})

-- vim-textobj-quote only in ~/docs/writing
autocmd({'BufEnter','BufNewFile','BufRead'}, {
  pattern = '*.md',
  callback = function()
    local cwd = vim.fn.expand('%:p')
    if cwd:find('/home/icy/docs/writing', 1, true) == 1 then
      vim.fn['textobj#quote#init']()
      vim.fn['pencil#init']({wrap = 'soft'})
      vim.keymap.set('i', '--', '—', {silent = true})
      vim.opt.breakindent = false
      vim.opt.shiftwidth = 4
      vim.opt.tabstop = 4
    end
  end
})

-- mdx files are markdown
autocmd({'BufEnter','BufNewFile','BufRead'}, {
  pattern = '*.mdx',
  callback = function()
    vim.bo.filetype = 'markdown'
  end
})

-- filetype.nvim
g.do_filetype_lua = 1
g.did_load_filetypes = 0

-- disable built-in plugins
local disabled_built_ins = {
  'gzip',
  'shada_plugin',
  'tarPlugin',
  'tar',
  'zipPlugin',
  'zip',
}

for i, _ in ipairs(disabled_built_ins) do
  g['loaded_' .. disabled_built_ins[i]] = 1
end

-- tmp
vim.g.gui_font_face = 'Noto Serif'