diff options
author | David Hollinger III <[email protected]> | 2021-05-24 17:01:24 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-24 18:01:24 -0400 |
commit | 7f8911d872fa250a688da3067df3a8144603989c (patch) | |
tree | 7c8f8c37659154db620f9df9e6b9c90d12e9e3c9 | |
parent | 4ebdcac7fa5c8c2b46137a66f3b688478ac8989b (diff) |
Add Go auto commands (#424)
-rw-r--r-- | lua/lv-autocommands/init.lua | 10 | ||||
-rw-r--r-- | lua/lv-globals.lua | 1 | ||||
-rw-r--r-- | lv-settings.lua | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/lua/lv-autocommands/init.lua b/lua/lv-autocommands/init.lua index 6e69de48..a7574f66 100644 --- a/lua/lv-autocommands/init.lua +++ b/lua/lv-autocommands/init.lua @@ -25,6 +25,9 @@ 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 +local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'} +if O.go.autoformat then table.insert(auto_formatters, go_format) end + utils.define_augroups({ _general_settings = { {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'}, @@ -40,6 +43,13 @@ utils.define_augroups({ {'FileType', 'java', 'luafile ~/.config/nvim/lua/lsp/java-ls.lua'}, {'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'} }, + _go = { + -- Go generally requires Tabs instead of spaces. + {'FileType', 'go', 'setlocal tabstop=4'}, + {'FileType', 'go', 'setlocal shiftwidth=4'}, + {'FileType', 'go', 'setlocal softtabstop=4'}, + {'FileType', 'go', 'setlocal noexpandtab'}, + }, _dashboard = { -- seems to be nobuflisted that makes my stuff disapear will do more testing { diff --git a/lua/lv-globals.lua b/lua/lv-globals.lua index a64bbbb8..bed92a45 100644 --- a/lua/lv-globals.lua +++ b/lua/lv-globals.lua @@ -64,6 +64,7 @@ O = { diagnostics = {virtualtext = {spacing = 0, prefix = "ï„‘"}, signs = true, underline = true}, filetypes = {'rb', 'erb', 'rakefile'} }, + go = {}, -- css = {formatter = '', autoformat = false, virtual_text = true}, -- json = {formatter = '', autoformat = false, virtual_text = true} diff --git a/lv-settings.lua b/lv-settings.lua index 826b95ea..7827a5d0 100644 --- a/lv-settings.lua +++ b/lv-settings.lua @@ -59,6 +59,9 @@ O.json.autoformat = true -- ruby O.ruby.autoformat = true + +-- go +O.go.autoformat = true -- create custom autocommand field (This would be easy with lua) -- Turn off relative_numbers |