diff options
| author | jdhao <jdhao@hotmail.com> | 2022-08-13 22:39:47 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-13 22:39:47 +0800 |
| commit | b331cddc73c559fe41807184f3b73abfcec86608 (patch) | |
| tree | ee33de2588f4d5267473ee4918d2d00fc3d8349e | |
| parent | 84d73660fa551f85c6a5236950c13b51e9756da4 (diff) | |
| parent | b11c57e36fccb1e4c4fe4a28ff8b0a36f4c14236 (diff) | |
Merge pull request #61 from jdhao/init.lua
Transition from init.vim to init.lua
| -rw-r--r-- | init.lua | 36 | ||||
| -rw-r--r-- | init.vim | 31 | ||||
| -rw-r--r-- | lua/utils.lua | 19 |
3 files changed, 55 insertions, 31 deletions
diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..b3f28c3 --- /dev/null +++ b/init.lua @@ -0,0 +1,36 @@ +-- This is my personal Nvim configuration supporting Mac, Linux and Windows, with various plugins configured. +-- This configuration evolves as I learn more about Nvim and become more proficient in using Nvim. +-- Since it is very long (more than 1000 lines!), you should read it carefully and take only the settings that suit you. +-- I would not recommend cloning this repo and replace your own config. Good configurations are personal, +-- built over time with a lot of polish. +-- +-- Author: Jie-dong Hao +-- Email: jdhao@hotmail.com +-- Blog: https://jdhao.github.io/ + +local utils = require "utils" +local match_res = utils.check_version_match() + +if not match_res.match then + local msg = string.format("Nvim version mistmatch: %s expected, but got %s instead!", match_res.expected, match_res.actual) + vim.api.nvim_echo({ { msg, "ErrorMsg" } }, false, {}) + return +end + +local core_conf_files = { + "globals.vim", + "options.vim", + "autocommands.vim", + "mappings.vim", + "plugins.vim", + "themes.vim", +} + +for _, name in ipairs(core_conf_files) do + local path = string.format("%s/core/%s", vim.fn.stdpath('config'), name) + local source_cmd = "source " .. path + vim.cmd(source_cmd) +end +-- for s:fname in s:core_conf_files +-- execute printf('source %s/core/%s', stdpath('config'), s:fname) +-- endfor diff --git a/init.vim b/init.vim deleted file mode 100644 index 52a648f..0000000 --- a/init.vim +++ /dev/null @@ -1,31 +0,0 @@ -" This is my personal Nvim configuration supporting Mac, Linux and Windows, with various plugins configured. -" This configuration evolves as I learn more about Nvim and become more proficient in using Nvim. -" Since it is very long (more than 1000 lines!), you should read it carefully and take only the settings that suit you. -" I would not recommend cloning this repo and replace your own config. Good configurations are personal, -" built over time with a lot of polish. -" -" Author: Jie-dong Hao -" Email: jdhao@hotmail.com -" Blog: https://jdhao.github.io/ - -" check if we have the lastest stable version of nvim -let s:expect_ver = printf('nvim-%s', '0.7.2') -let s:actual_ver = matchstr(execute('version'), 'NVIM v\zs[^\n]*') - -if !has(s:expect_ver) - echohl Error | echomsg printf("%s required, but got nvim %s!", s:expect_ver, s:actual_ver) | echohl None - finish -endif - -let s:core_conf_files = [ - \ 'globals.vim', - \ 'options.vim', - \ 'autocommands.vim', - \ 'mappings.vim', - \ 'plugins.vim', - \ 'themes.vim' - \ ] - -for s:fname in s:core_conf_files - execute printf('source %s/core/%s', stdpath('config'), s:fname) -endfor diff --git a/lua/utils.lua b/lua/utils.lua index a6fd11a..13044da 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -25,4 +25,23 @@ function M.may_create_dir() end end +function M.check_version_match() + -- check if we have the lastest stable version of nvim + local expected_ver = {major = 0, minor = 7, patch = 2} + local actual_ver = vim.version() + + local ver_match = true + for key, val in pairs(expected_ver) do + if val ~= actual_ver[key] then + ver_match = false + break + end + end + + local expect_ver_str = string.format("%s.%s.%s", expected_ver.major, expected_ver.minor, expected_ver.patch) + local nvim_ver_str = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch) + + return {match=ver_match, expected=expect_ver_str, actual=nvim_ver_str} +end + return M |
