100 lines
3.1 KiB
Lua
100 lines
3.1 KiB
Lua
-- Load tokyonight color scheme plugin
|
|
vim.opt.rtp:prepend("~/.config/nvim/holtrop.nvim/tokyonight.nvim")
|
|
vim.cmd([[colorscheme tokyonight-night]])
|
|
|
|
-- Load fzf-lua plugin
|
|
vim.opt.rtp:prepend("~/.config/nvim/holtrop.nvim/fzf-lua.nvim")
|
|
vim.cmd([[runtime plugin/fzf-lua.lua]])
|
|
require('fzf-lua').setup({
|
|
winopts = {
|
|
preview = {
|
|
layout = 'vertical',
|
|
vertical = 'down:50%',
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Show titlestring in GUI window title
|
|
vim.opt.title = true
|
|
vim.opt.titlestring = "%t%m%r%{exists('g:project_name') ? ' : '.g:project_name : ''}"
|
|
vim.opt.modeline = false
|
|
vim.opt.colorcolumn = "80"
|
|
vim.opt.cursorcolumn = true
|
|
vim.opt.cursorline = true
|
|
vim.opt.so = 8
|
|
vim.opt.wildmode = {'list:longest'}
|
|
vim.opt.splitbelow = true
|
|
vim.opt.splitright = true
|
|
vim.g.editorconfig = false
|
|
-- Following are also set in the BufReadPost autocommand below
|
|
vim.opt.expandtab = true
|
|
vim.opt.ts = 4
|
|
vim.opt.sw = 4
|
|
vim.opt.sts = 4
|
|
vim.opt.cinoptions = ":0,g0"
|
|
|
|
local holtrop_bufread_group = vim.api.nvim_create_augroup("holtrop_bufread_group", { clear = true })
|
|
|
|
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
|
|
group = holtrop_bufread_group,
|
|
pattern = "*",
|
|
callback = function()
|
|
vim.schedule(function()
|
|
if vim.bo.filetype ~= "make" then
|
|
vim.opt_local.expandtab = true
|
|
end
|
|
vim.opt_local.ts = 4
|
|
vim.opt_local.sw = 4
|
|
vim.opt_local.sts = 4
|
|
vim.opt_local.cinoptions = ":0,g0"
|
|
end)
|
|
end,
|
|
})
|
|
|
|
-- Restore cursor position after opening a file
|
|
local cursor_group = vim.api.nvim_create_augroup("holtrop_restore_cursor", { clear = true })
|
|
|
|
vim.api.nvim_create_autocmd("BufReadPost", {
|
|
group = cursor_group,
|
|
pattern = "*",
|
|
callback = function()
|
|
-- Get the row and column of the last cursor position mark
|
|
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
|
local lcount = vim.api.nvim_buf_line_count(0)
|
|
|
|
-- If the mark is valid, jump to it, unless it's a git commit message
|
|
if mark[1] > 0 and mark[1] <= lcount and vim.bo.filetype ~= "gitcommit" then
|
|
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
|
end
|
|
end,
|
|
})
|
|
|
|
-- Shortcuts
|
|
vim.cmd([[map <C-s> :FzfLua combine pickers=buffers,git_files<CR>]])
|
|
vim.cmd([[map f<C-s> :FzfLua combine pickers=buffers,files<CR>]])
|
|
vim.cmd([[inoremap <C-Enter> <Esc>O]])
|
|
vim.cmd([[vnoremap < <gv]])
|
|
vim.cmd([[vnoremap > >gv]])
|
|
vim.cmd([[nnoremap <silent> ,t :tabn<CR>]])
|
|
vim.cmd([[nnoremap <silent> ,T :tabp<CR>]])
|
|
vim.cmd([[nnoremap <silent> <C-S-PageUp> :tabmove -1<CR>]])
|
|
vim.cmd([[nnoremap <silent> <C-S-PageDown> :tabmove +1<CR>]])
|
|
vim.cmd([[nnoremap <silent> ,j Ji<CR><Esc>]])
|
|
vim.cmd([[nnoremap ,s :%s/\v +$//<CR>]])
|
|
|
|
-- Use system clipboard for unnamed register
|
|
vim.opt.clipboard = "unnamedplus"
|
|
|
|
-- Reload file automatically if changed externally
|
|
vim.o.autoread = true
|
|
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter" }, {
|
|
group = vim.api.nvim_create_augroup("AutoRead", { clear = true }),
|
|
callback = function()
|
|
if vim.fn.mode() ~= 'c' then
|
|
vim.cmd("checktime")
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.filetype.add({filename = {["Rsconscript"] = "ruby"}})
|