diff options
| author | nsfisis <nsfisis@gmail.com> | 2022-12-19 00:08:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2022-12-19 00:10:21 +0900 |
| commit | 755f17948a95df8b0c6793310ce8abc448dd2b2d (patch) | |
| tree | 5bdab6a14198f7e9ea801524d5b9174787eed54a /.config/nvim/lua/vimrc.lua | |
| parent | 4b0d3648f1e8599bbdeba64214a6a65a219ec4e1 (diff) | |
| download | dotfiles-755f17948a95df8b0c6793310ce8abc448dd2b2d.tar.gz dotfiles-755f17948a95df8b0c6793310ce8abc448dd2b2d.tar.zst dotfiles-755f17948a95df8b0c6793310ce8abc448dd2b2d.zip | |
neovim: refactor
Diffstat (limited to '.config/nvim/lua/vimrc.lua')
| -rw-r--r-- | .config/nvim/lua/vimrc.lua | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/.config/nvim/lua/vimrc.lua b/.config/nvim/lua/vimrc.lua deleted file mode 100644 index 65d229e..0000000 --- a/.config/nvim/lua/vimrc.lua +++ /dev/null @@ -1,150 +0,0 @@ -local M = {} - - - -local vimrc_augroup - -function M.create_augroup_for_vimrc() - vimrc_augroup = vim.api.nvim_create_augroup('Vimrc', {}) -end - -function M.autocmd(event, opts) - if not opts.group then - opts.group = vimrc_augroup - end - vim.api.nvim_create_autocmd(event, opts) -end - - - -function M.after_ftplugin(ft, callback) - local var_name = 'did_ftplugin_' .. ft .. '_after' - if vim.b[var_name] ~= nil then - return - end - - callback(conf) - - vim.b[var_name] = true -end - - - -local function set_indentation(style, width) - vim.bo.expandtab = style - vim.bo.tabstop = width - vim.bo.shiftwidth = width - vim.bo.softtabstop = width -end - - -function M.register_filetype_autocmds_for_indentation() - local SPACE = true - local TAB = false - - local indentation_settings = { - c = { style = SPACE, width = 4 }, - cmake = { style = SPACE, width = 2 }, - cpp = { style = SPACE, width = 4 }, - css = { style = SPACE, width = 2 }, - docbk = { style = SPACE, width = 2 }, - go = { style = TAB, width = 4 }, - haskell = { style = SPACE, width = 4 }, - html = { style = SPACE, width = 2 }, - javascript = { style = SPACE, width = 2 }, - json = { style = SPACE, width = 2 }, - leaf = { style = SPACE, width = 4 }, - lisp = { style = SPACE, width = 2 }, - lua = { style = SPACE, width = 3 }, - markdown = { style = SPACE, width = 4 }, - php = { style = SPACE, width = 2 }, - python = { style = SPACE, width = 4 }, - ruby = { style = SPACE, width = 2 }, - toml = { style = SPACE, width = 2 }, - typescript = { style = SPACE, width = 2 }, - vim = { style = SPACE, width = 4 }, - xml = { style = SPACE, width = 2 }, - yaml = { style = SPACE, width = 2 }, - } - - for ft, setting in pairs(indentation_settings) do - vimrc.autocmd('FileType', { - pattern = ft, - callback = function() - set_indentation(setting.style, setting.width) - end, - }) - end -end - - - -function M.hi(group, attributes) - vim.cmd(('highlight! %s %s'):format(group, attributes)) -end - - -function M.hi_link(from, to) - vim.cmd(('highlight! link %s %s'):format(from, to)) -end - - -M.map_callbacks = {} - - - --- Wrapper of |getchar()|. -function M.getchar() - local ch = vim.fn.getchar() - while ch == "\\<CursorHold>" do - ch = vim.fn.getchar() - end - return type(ch) == 'number' and vim.fn.nr2char(ch) or ch -end - - --- Wrapper of |:echo| and |:echohl|. -function M.echo(message, hl) - if not hl then - hl = 'None' - end - vim.cmd('redraw') - vim.api.nvim_echo({{ message, hl }}, false, {}) -end - - --- Wrapper of |getchar()|. -function M.getchar_with_prompt(prompt) - M.echo(prompt, 'Question') - return M.getchar() -end - - --- Wrapper of |input()|. --- Only when it is used in a mapping, |inputsave()| and |inputstore()| are --- required. -function M.input(prompt) - vim.fn.inputsave() - local result = vim.fn.input(prompt) - vim.fn.inputrestore() - return result -end - - -function M.term(s) - return vim.api.nvim_replace_termcodes(s, true, true, true) -end - - - -function M.iabbrev(from, to) - vim.cmd(('inoreabbrev %s %s'):format(from, to)) -end - - -function M.cabbrev(from, to) - vim.cmd(('cnoreabbrev %s %s'):format(from, to)) -end - - -return M |
