diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 9ead5e5..b5fab6a 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -1,3 +1,4 @@ +local fn = vim.fn local api = vim.api local lsp = vim.lsp @@ -135,9 +136,9 @@ if utils.executable('bash-language-server') then }) end -local sumneko_binary_path = vim.fn.exepath("lua-language-server") +local sumneko_binary_path = fn.exepath("lua-language-server") if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then - local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ":h:h:h") + local sumneko_root_path = fn.fnamemodify(sumneko_binary_path, ":h:h:h") local runtime_path = vim.split(package.path, ";") table.insert(runtime_path, "lua/?.lua") @@ -173,10 +174,10 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then end -- Change diagnostic signs. -vim.fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" }) -vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" }) -vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" }) -vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) +fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" }) +fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" }) +fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" }) +fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) -- global config for diagnostic vim.diagnostic.config({ diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua index 85e6e46..ff69060 100644 --- a/lua/config/statusline.lua +++ b/lua/config/statusline.lua @@ -1,3 +1,5 @@ +local fn = vim.fn + local function spell() if vim.o.spell then return string.format("[SPELL]") @@ -9,7 +11,7 @@ end local function ime_state() if vim.g.is_mac then -- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11 - local layout = vim.fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '') + local layout = fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '') if layout == '0' then return '[CN]' end @@ -35,20 +37,20 @@ end local function mixed_indent() local space_pat = [[\v^ +]] local tab_pat = [[\v^\t+]] - local space_indent = vim.fn.search(space_pat, 'nwc') - local tab_indent = vim.fn.search(tab_pat, 'nwc') + local space_indent = fn.search(space_pat, 'nwc') + local tab_indent = fn.search(tab_pat, 'nwc') local mixed = (space_indent > 0 and tab_indent > 0) local mixed_same_line if not mixed then - mixed_same_line = vim.fn.search([[\v^(\t+ | +\t)]], 'nwc') + mixed_same_line = fn.search([[\v^(\t+ | +\t)]], 'nwc') mixed = mixed_same_line > 0 end if not mixed then return '' end if mixed_same_line ~= nil and mixed_same_line > 0 then return 'MI:'..mixed_same_line end - local space_indent_cnt = vim.fn.searchcount({pattern=space_pat, max_count=1e3}).total - local tab_indent_cnt = vim.fn.searchcount({pattern=tab_pat, max_count=1e3}).total + local space_indent_cnt = fn.searchcount({pattern=space_pat, max_count=1e3}).total + local tab_indent_cnt = fn.searchcount({pattern=tab_pat, max_count=1e3}).total if space_indent_cnt > tab_indent_cnt then return 'MI:'..tab_indent else diff --git a/lua/plugins.lua b/lua/plugins.lua index 6065efb..9376e91 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -359,7 +359,7 @@ require("packer").startup({ end, config = { max_jobs = 16, - compile_path = util.join_paths(vim.fn.stdpath('data'), 'site', 'lua', 'packer_compiled.lua'), + compile_path = util.join_paths(fn.stdpath('data'), 'site', 'lua', 'packer_compiled.lua'), }, }) diff --git a/lua/utils.lua b/lua/utils.lua index c04f64b..a6fd11a 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -1,3 +1,5 @@ +local fn = vim.fn + -- inspect something function inspect(item) vim.pretty_print(item) @@ -6,7 +8,7 @@ end local M = {} function M.executable(name) - if vim.fn.executable(name) > 0 then + if fn.executable(name) > 0 then return true end @@ -14,12 +16,12 @@ function M.executable(name) end function M.may_create_dir() - local fpath = vim.fn.expand('') - local parent_dir = vim.fn.fnamemodify(fpath, ":p:h") - local res = vim.fn.isdirectory(parent_dir) + local fpath = fn.expand('') + local parent_dir = fn.fnamemodify(fpath, ":p:h") + local res = fn.isdirectory(parent_dir) if res == 0 then - vim.fn.mkdir(parent_dir, 'p') + fn.mkdir(parent_dir, 'p') end end