1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- -- change terminal title
- vim.o.title = true
- -- default indentation
- vim.o.shiftwidth = 2
- vim.o.tabstop = 4
- vim.o.expandtab = true
- -- permanent undo history
- vim.o.undofile = true
- -- allow switching buffers
- vim.o.hidden = true
- -- always scroll (keep current line vertically centered)
- vim.o.scrolloff = 999
- -- show line numbers
- vim.o.number = true
- vim.o.relativenumber = true
- -- set wordwrap indent
- vim.o.wrap = false
- vim.o.linebreak = true
- vim.o.breakindent = true
- vim.o.breakindentopt = 'shift:2,sbr'
- -- show whitespace
- vim.o.list = true
- -- disable search highlight
- vim.o.hlsearch = false
- -- always show sign column to avoid layout shift when staging
- vim.o.signcolumn = 'yes'
- -- have preview window be a bit taller
- vim.o.previewheight = 20
- -- make a new copy of the file for backup
- -- setting to no or auto messes with filewatchers
- vim.o.backupcopy = 'yes'
- -- disable modelines
- vim.o.modeline = false
- -- show preview of lines when using :s
- vim.o.inccommand = 'split'
- -- mouse only in visual mode
- vim.o.mouse = 'v'
- -- use POSIX-y shell for !
- vim.o.shell = '/bin/sh'
- -- diff options, increase linematch to 60 and use histogram algorithm
- vim.o.diffopt = 'internal,filler,closeoff,linematch:60,algorithm:histogram'
- -- basic keymaps
- -- j/k with wraps
- vim.keymap.set({ 'n', 'v' }, 'j', 'gj')
- vim.keymap.set({ 'n', 'v' }, 'k', 'gk')
- -- select pasted text
- vim.keymap.set('n', 'gp', '`[v`]')
- -- format on save
- vim.api.nvim_create_autocmd('BufWritePre', {
- callback = function(opts)
- if vim.bo.filetype == 'diff' then
- return
- end
- if not vim.g.no_lsp_format then
- -- check if can LSP format
- local clients = vim.lsp.get_clients({ bufnr = opts.buf, method = 'textDocument/formatting' })
- if #clients > 0 then
- vim.lsp.buf.format({ bufnr = opts.buf })
- end
- end
- -- otherwise strip trailing whitespace
- vim.cmd('%s/\\s\\+$//e')
- end,
- })
|