浏览代码

Add autoformatting for ruby (#305)

rebuilt 4 年之前
父节点
当前提交
1eb8339a47
共有 2 个文件被更改,包括 5 次插入0 次删除
  1. 3 0
      lua/lv-autocommands/init.lua
  2. 2 0
      lv-settings.lua

+ 3 - 0
lua/lv-autocommands/init.lua

@@ -18,6 +18,9 @@ if O.lua.autoformat then table.insert(auto_formatters, lua_format) end
 local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
 if O.json.autoformat then table.insert(auto_formatters, json_format) end
 
+local ruby_format = {'BufWritePre', '*.rb', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
+if O.ruby.autoformat then table.insert(auto_formatters, ruby_format) end
+
 utils.define_augroups({
     _general_settings = {
         {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},

+ 2 - 0
lv-settings.lua

@@ -49,4 +49,6 @@ O.tsserver.autoformat = true
 -- json
 O.json.autoformat = true
 
+-- ruby
+O.ruby.autoformat = true
 -- create custom autocommand field (This would be easy with lua)