185 lines
4.8 KiB
Lua
185 lines
4.8 KiB
Lua
local tool = require("util.tool")
|
||
|
||
local options = {
|
||
background = "dark",
|
||
completeopt = 'menu,menuone,noselect,popup',
|
||
cursorline = true,
|
||
|
||
autoindent = true,
|
||
expandtab = true,
|
||
fileformat = "unix",
|
||
|
||
encoding = "utf-8",
|
||
fileencoding = "utf-8",
|
||
fileencodings = "utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936",
|
||
foldenable = true,
|
||
foldlevel = 1,
|
||
foldlevelstart = 99,
|
||
foldmethod = "syntax",
|
||
gdefault = true,
|
||
hlsearch = true,
|
||
incsearch = true,
|
||
ignorecase = true,
|
||
jumpoptions = "stack",
|
||
mouse = "",
|
||
number = true,
|
||
ruler = true,
|
||
relativenumber = true,
|
||
showcmd = true,
|
||
showmode = false,
|
||
shortmess = "atI",
|
||
signcolumn = "yes",
|
||
scrolljump = 5,
|
||
scrolloff = 3,
|
||
smartcase = true,
|
||
smartindent = true,
|
||
|
||
softtabstop = 4,
|
||
shiftwidth = 4,
|
||
tabstop = 4,
|
||
|
||
textwidth = 120,
|
||
termguicolors = true,
|
||
undofile = true,
|
||
winminheight = 0,
|
||
wildignore = {"*.o", "*.dll", "*.exe", "*.so", "*.pyc", "*.class", "node_modules"},
|
||
wildmenu = true,
|
||
wildmode = "list:longest,full",
|
||
whichwrap = "b,s,<,>,[,]",
|
||
|
||
-- list = true,
|
||
-- listchars = 'tab:»·,nbsp:+,trail:·,extends:→,precedes:←',
|
||
-- fillchars = {
|
||
-- stl = ' ',
|
||
-- stlnc = '-',
|
||
-- msgsep = ' ',
|
||
-- foldopen = '',
|
||
-- foldclose = '',
|
||
-- fold = ' ',
|
||
-- foldsep = ' ',
|
||
-- diff = '╱',
|
||
-- eob = ' ',
|
||
-- },
|
||
}
|
||
|
||
for k, v in pairs(options) do
|
||
vim.opt[k] = v
|
||
end
|
||
|
||
vim.opt.clipboard:append("unnamedplus")
|
||
vim.g.mapleader = ","
|
||
-- vim.g.solarized_termcolors = 256
|
||
-- vim.cmd([[set clipboard+=unnamedplus]])
|
||
if vim.fn.exists("$SSH_TTY") == 1 and vim.env.TMUX == nil then
|
||
vim.g.clipboard = {
|
||
name = "OSC 52",
|
||
copy = {
|
||
["+"] = require("vim.ui.clipboard.osc52").copy("+"),
|
||
["*"] = require("vim.ui.clipboard.osc52").copy("*"),
|
||
},
|
||
paste = {
|
||
["+"] = require("vim.ui.clipboard.osc52").paste("+"),
|
||
["*"] = require("vim.ui.clipboard.osc52").paste("*"),
|
||
},
|
||
}
|
||
end
|
||
|
||
vim.cmd([[syntax on]])
|
||
-- vim.cmd("set whichwrap=b,s,<,>,[,]")
|
||
|
||
vim.api.nvim_create_autocmd({"BufNewFile", "BufRead"}, {
|
||
pattern = { "*.yaml", "*.yml", "*.json", "*.ps1", "*.psm1", "*.psd1", "*.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
|
||
|
||
if vim.fn.has("win32") then
|
||
if tool.has_cmd("pwsh") then
|
||
vim.api.nvim_set_var("terminal_emulator", "pwsh")
|
||
vim.opt.shell = "pwsh"
|
||
vim.opt.shellcmdflag = "-nologo -ExecutionPolicy RemoteSigned -command"
|
||
vim.opt.shellxquote = ""
|
||
elseif tool.has_cmd("powershell") then
|
||
vim.api.nvim_set_var("terminal_emulator", "powershell")
|
||
vim.opt.shell = "powershell"
|
||
vim.opt.shellcmdflag = "-nologo -ExecutionPolicy RemoteSigned -command"
|
||
vim.opt.shellxquote = ""
|
||
end
|
||
end
|
||
|
||
vim.filetype.add({
|
||
extension = {
|
||
['http'] = 'http',
|
||
},
|
||
})
|