149 lines
3.8 KiB
Lua
149 lines
3.8 KiB
Lua
local M = {}
|
|
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 = "syntax",
|
|
foldlevel=1,
|
|
foldlevelstart = 99,
|
|
textwidth = 120,
|
|
}
|
|
|
|
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
|
|
|
|
M.ghproxy = "https://ghproxy.net/"
|
|
|
|
M.has_cmd = function(cmd)
|
|
local res = vim.fn.executable(cmd)
|
|
return res == 1
|
|
end
|
|
|
|
return M
|