notes/config/nvim/lua/neo/option.lua

126 lines
3.2 KiB
Lua

local options = {
termguicolors = true,
ruler = true,
background = "dark",
number = true,
relativenumber = true,
showcmd = true,
cursorline = true,
shortmess = "atI",
incsearch = true,
hlsearch = true,
winminheight = 0,
ignorecase = true,
smartcase = true,
wildmenu = true,
wildmode = "list:longest,full",
scrolljump = 5,
scrolloff = 3,
foldenable = true,
gdefault = true,
encoding = "utf-8",
fileencoding = "utf-8",
fileencodings = "utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936",
expandtab = true,
autoindent = true,
fileformat = "unix",
tabstop = 4,
softtabstop = 4,
shiftwidth = 4,
foldmethod = indent,
textwidth = 120
}
for k, v in pairs(options) do
vim.opt[k] = v
end
vim.g.mapleader = ','
vim.g.solarized_termcolors = 256
vim.cmd([[syntax on]])
vim.cmd("set whichwrap=b,s,h,l,<,>,[,]")
vim.cmd([[set clipboard+=unnamedplus]])
-- set global config var
-- vim.api.nvim_set_var('solarized_termcolors', 256)
vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, {
pattern = { "*.yaml", "*.yml", "*.json", "*.ps1", "*.lua", },
command = [[set tabstop=2 softtabstop=2 shiftwidth=2]]
})
vim.api.nvim_create_autocmd("FileType", {
pattern = { "vim", "vimrc", },
command = [[set tabstop=2 softtabstop=2 shiftwidth=2]]
})
vim.api.nvim_create_autocmd({"FileType"}, {
pattern = {"gitconfig"},
command = [[set tabstop=4 softtabstop=4 shiftwidth=4]]
})
vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, {
pattern = { "*.py" },
command = [[set tabstop=4 softtabstop=4 shiftwidth=4]]
})
vim.cmd("nnoremap ; :")
-- vim.api.nvim_set_keymap('n', ';', ':', {
-- silent = true,
-- noremap = true
-- })
-- vim.keymap.set('n', ';', ':', {noremap = true, silent = true})
--vim.api.nvim_set_keymap('i', 'HH', '<Home>', {
-- silent = true,
-- noremap = true
--})
-- vim.api.nvim_set_keymap('i', 'LL', '<End>', {
-- silent = true,
-- noremap = true
-- })
-- autocmd BufWinEnter quickfix nnoremap <silent> <buffer>
-- \ q :cclose<cr>:lclose<cr>
-- autocmd BufEnter * if (winnr('$') == 1 && &buftype ==# 'quickfix' ) |
-- \ bd|
-- \ q | endif
vim.api.nvim_create_autocmd("BufWinEnter", {
pattern = {"quickfix"},
command = [[nnoremap <silent><buffer>q :cclose<CR>:lclose<CR>]]
})
vim.api.nvim_create_autocmd("BufEnter", {
pattern = {"*"},
command = [[if (winnr('$') == 1 && &buftype ==# 'quickfix') | bd | q | endif]]
})
-- Trim space at end of line
-- Add silent! to ignore warnings and errors
vim.cmd([[
func! s:TrimAll()
exec('%s/\s\+$//g')
endfunc
command! -nargs=* -complete=file TrimAll :silent! call s:TrimAll()
]])
-- func! provider#clipboard#Executable() abort
-- if exists('g:clipboard')
-- if type({}) isnot# type(g:clipboard)
-- \ || type({}) isnot# type(get(g:clipboard, 'copy', v:null))
-- \ || type({}) isnot# type(get(g:clipboard, 'paste', v:null))
-- let s:err = 'clipboard: invalid g:clipboard'
-- return ''
-- endif
-- let s:copy = get(g:clipboard, 'copy', { '+': v:null, '*': v:null })
-- let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null })
-- let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0)
-- return get(g:clipboard, 'name', 'g:clipboard')
-- endfunc