1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:30:05 +08:00

feat(default): add default.lua

This commit is contained in:
Wang Shidong 2022-09-11 14:46:52 +08:00 committed by GitHub
parent 1eb887032d
commit 79c5576fd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 159 additions and 2 deletions

View File

@ -1708,7 +1708,11 @@ function! SpaceVim#begin() abort
else
call SpaceVim#logger#info('Startup with argv: ' . string(s:status[1]) )
endif
call SpaceVim#default#options()
if has('nvim-0.7')
lua require('spacevim.default').options()
else
call SpaceVim#default#options()
endif
call SpaceVim#default#layers()
call SpaceVim#commands#load()
endfunction

View File

@ -20,7 +20,6 @@ function! SpaceVim#default#options() abort
set guioptions-=L " Hide left-hand scrollbar
set guioptions-=r " Hide right-hand scrollbar
set guioptions-=b " Hide bottom scrollbar
set showtabline=0 " Hide tabline
set guioptions-=e " Hide tab
try
if s:SYSTEM.isWindows

154
lua/spacevim/default.lua Normal file
View File

@ -0,0 +1,154 @@
--=============================================================================
-- default.lua --- default option
-- Copyright (c) 2016-2019 Wang Shidong & Contributors
-- Author: Wang Shidong < wsdjeg@outlook.com >
-- URL: https://spacevim.org
-- License: GPLv3
--=============================================================================
local M = {}
local SYSTEM = require('spacevim.api').import('system')
local guifont = ''
local function set_font(font)
vim.o.guifont = font
end
function M.options()
if vim.fn.has('gui_running') == 1 then
vim.opt.guioptions:remove(
{
'm', -- hide menu bar
'T', -- hide toolbar
'L', -- hide left-hand scrollbar
'r', -- hide right-hand scrollbar
'b', -- hide bottom scrollbar
'e', -- hide tab
}
)
if SYSTEM.isWindows then
guifont = 'DejaVu_Sans_Mono_for_Powerline:h11:cANSI:qDRAFT'
elseif SYSTEM.isOSX then
guifont = 'DejaVu Sans Mono for Powerline:h11'
else
guifont = 'DejaVu Sans Mono for Powerline 11'
end
local ok, errors = pcall(set_font, guifont)
if not ok then
print(errors)
end
end
-- indent use backspace delete indent, eol use backspace delete line at
-- begining start delete the char you just typed in if you do not use set
-- nocompatible ,you need this
vim.o.backspace = 'indent,eol,start'
vim.opt.nrformats:remove({'octal'})
vim.o.listchars = 'tab:→ ,eol:↵,trail:·,extends:↷,precedes:↶'
vim.o.fillchars = 'vert:│,fold:·'
vim.o.laststatus = 2
vim.o.showcmd = false
vim.o.autoindent = true
vim.o.linebreak = true
vim.o.wildmenu = true
vim.o.linebreak = true
vim.o.number = true
vim.o.autoread = true
vim.o.backup = true
vim.o.undofile = true
vim.o.undolevels = 1000
if vim.fn.has('nvim-0.5.0') == 1 then
vim.g.data_dir = vim.g.spacevim_data_dir .. 'SpaceVim/'
else
vim.g.data_dir = vim.g.spacevim_data_dir .. 'SpaceVim/old/'
end
vim.g.backup_dir = vim.g.data_dir .. 'backup//'
vim.g.swap_dir = vim.g.data_dir .. 'swap//'
vim.g.undo_dir = vim.g.data_dir .. 'undofile//'
vim.g.conf_dir = vim.g.data_dir .. 'conf'
if vim.fn.finddir(vim.g.data_dir) == '' then
vim.fn.mkdir(vim.g.data_dir, 'p', 0700)
end
if vim.fn.finddir(vim.g.backup_dir) == '' then
vim.fn.mkdir(vim.g.backup_dir, 'p', 0700)
end
if vim.fn.finddir(vim.g.swap_dir) == '' then
vim.fn.mkdir(vim.g.swap_dir, 'p', 0700)
end
if vim.fn.finddir(vim.g.undo_dir) == '' then
vim.fn.mkdir(vim.g.undo_dir, 'p', 0700)
end
if vim.fn.finddir(vim.g.conf_dir) == '' then
vim.fn.mkdir(vim.g.conf_dir, 'p', 0700)
end
vim.o.undodir = vim.g.undo_dir
vim.o.backupdir = vim.g.backup_dir
vim.o.directory = vim.g.swap_dir
vim.g.data_dir = nil
vim.g.backup_dir = nil
vim.g.swap_dir = nil
vim.g.undo_dir = nil
vim.g.conf_dir = nil
vim.o.writebackup = false
vim.o.matchtime = 0
vim.o.ruler = true
vim.o.showmatch = true
vim.o.showmode = true
vim.o.completeopt = 'menu,menuone,longest'
vim.o.complete = '.,w,b,u,t'
vim.o.pumheight = 15
vim.o.scrolloff = 1
vim.o.sidescrolloff = 5
vim.opt.display = vim.opt.display + {'lastline'}
vim.o.incsearch = true
vim.o.hlsearch = true
vim.o.wildignorecase = true
vim.o.mouse = 'nv'
vim.o.hidden = true
vim.o.ttimeout = true
vim.o.ttimeoutlen = 50
if vim.fn.has('patch-7.4.314') == 1 then
-- don't give ins-completion-menu messages.
vim.opt.shortmess:append('c')
end
vim.opt.shortmess:append('s')
-- Do not wrap lone lines
vim.o.wrap = false
vim.o.foldtext = 'SpaceVim#default#Customfoldtext()'
end
return M