When add the following code, max_line_len works well:
local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').gofmt()
end,
group = format_sync_grp,
})
the complete init_lazy.lua
```lua
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/lazy]])
local package_root = '/tmp/nvim/lazy'
local plugin_folder = function()
local host = os.getenv('HOST_NAME')
if host and (host:find('Ray') or host:find('ray')) then
return [[~/github/ray-x]] -- vim.fn.expand("$HOME") .. '/github/'
else
return ''
end
end
local lazypath = package_root .. '/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local function load_plugins()
return {
{
'nvim-treesitter/nvim-treesitter',
config = function()
require('nvim-treesitter.configs').setup({
ensure_installed = { 'go' },
highlight = { enable = true },
})
end,
build = ':TSUpdate',
},
{ 'neovim/nvim-lspconfig' },
{
'ray-x/go.nvim',
dev = (plugin_folder() ~= ''),
-- dev = true,
ft = 'go',
dependencies = {
'mfussenegger/nvim-dap', -- Debug Adapter Protocol
'rcarriga/nvim-dap-ui',
'theHamsta/nvim-dap-virtual-text',
'ray-x/guihua.lua',
},
config = true,
opts = {
verbose = true,
max_line_len = 120,
lsp_cfg = {
handlers = {
['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'double' }),
['textDocument/signatureHelp'] = vim.lsp.with(
vim.lsp.handlers.signature_help,
{ border = 'round' }
),
},
}, -- false: do nothing
}
},
}
end
local opts = {
root = package_root, -- directory where plugins will be installed
default = { lazy = true },
dev = {
-- directory where you store your local plugin projects
path = plugin_folder(),
},
}
local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').gofmt()
end,
group = format_sync_grp,
})
require('lazy').setup(load_plugins(), opts)
vim.cmd('colorscheme murphy')
```
But if I add the following code, max_line_len didn't work:
local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').goimport()
end,
group = format_sync_grp,
})
the complete init_lazy.lua
```lua
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/lazy]])
local package_root = '/tmp/nvim/lazy'
local plugin_folder = function()
local host = os.getenv('HOST_NAME')
if host and (host:find('Ray') or host:find('ray')) then
return [[~/github/ray-x]] -- vim.fn.expand("$HOME") .. '/github/'
else
return ''
end
end
local lazypath = package_root .. '/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local function load_plugins()
return {
{
'nvim-treesitter/nvim-treesitter',
config = function()
require('nvim-treesitter.configs').setup({
ensure_installed = { 'go' },
highlight = { enable = true },
})
end,
build = ':TSUpdate',
},
{ 'neovim/nvim-lspconfig' },
{
'ray-x/go.nvim',
dev = (plugin_folder() ~= ''),
-- dev = true,
ft = 'go',
dependencies = {
'mfussenegger/nvim-dap', -- Debug Adapter Protocol
'rcarriga/nvim-dap-ui',
'theHamsta/nvim-dap-virtual-text',
'ray-x/guihua.lua',
},
config = true,
opts = {
verbose = true,
max_line_len = 120,
lsp_cfg = {
handlers = {
['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'double' }),
['textDocument/signatureHelp'] = vim.lsp.with(
vim.lsp.handlers.signature_help,
{ border = 'round' }
),
},
}, -- false: do nothing
}
},
}
end
local opts = {
root = package_root, -- directory where plugins will be installed
default = { lazy = true },
dev = {
-- directory where you store your local plugin projects
path = plugin_folder(),
},
}
local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').goimport()
end,
group = format_sync_grp,
})
require('lazy').setup(load_plugins(), opts)
vim.cmd('colorscheme murphy')
```
Summary:
If I want to use gofumpt, goimports, then golines doesn't work. (case 2)
If I use gofumpt and golines, then I cann't use goimports. (case 1)
Would there be a way to make these commands works together when I save the file?
I use init_lazy.lua to make the test.
I add the
max_line_len
config in the config file:When add the following code,
max_line_len
works well:the complete init_lazy.lua
```lua vim.cmd([[set runtimepath=$VIMRUNTIME]]) vim.cmd([[set packpath=/tmp/nvim/lazy]]) local package_root = '/tmp/nvim/lazy' local plugin_folder = function() local host = os.getenv('HOST_NAME') if host and (host:find('Ray') or host:find('ray')) then return [[~/github/ray-x]] -- vim.fn.expand("$HOME") .. '/github/' else return '' end end local lazypath = package_root .. '/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', -- latest stable release lazypath, }) end vim.opt.rtp:prepend(lazypath) local function load_plugins() return { { 'nvim-treesitter/nvim-treesitter', config = function() require('nvim-treesitter.configs').setup({ ensure_installed = { 'go' }, highlight = { enable = true }, }) end, build = ':TSUpdate', }, { 'neovim/nvim-lspconfig' }, { 'ray-x/go.nvim', dev = (plugin_folder() ~= ''), -- dev = true, ft = 'go', dependencies = { 'mfussenegger/nvim-dap', -- Debug Adapter Protocol 'rcarriga/nvim-dap-ui', 'theHamsta/nvim-dap-virtual-text', 'ray-x/guihua.lua', }, config = true, opts = { verbose = true, max_line_len = 120, lsp_cfg = { handlers = { ['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'double' }), ['textDocument/signatureHelp'] = vim.lsp.with( vim.lsp.handlers.signature_help, { border = 'round' } ), }, }, -- false: do nothing } }, } end local opts = { root = package_root, -- directory where plugins will be installed default = { lazy = true }, dev = { -- directory where you store your local plugin projects path = plugin_folder(), }, } local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {}) vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*.go", callback = function() require('go.format').gofmt() end, group = format_sync_grp, }) require('lazy').setup(load_plugins(), opts) vim.cmd('colorscheme murphy') ```But if I add the following code,
max_line_len
didn't work:the complete init_lazy.lua
```lua vim.cmd([[set runtimepath=$VIMRUNTIME]]) vim.cmd([[set packpath=/tmp/nvim/lazy]]) local package_root = '/tmp/nvim/lazy' local plugin_folder = function() local host = os.getenv('HOST_NAME') if host and (host:find('Ray') or host:find('ray')) then return [[~/github/ray-x]] -- vim.fn.expand("$HOME") .. '/github/' else return '' end end local lazypath = package_root .. '/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', -- latest stable release lazypath, }) end vim.opt.rtp:prepend(lazypath) local function load_plugins() return { { 'nvim-treesitter/nvim-treesitter', config = function() require('nvim-treesitter.configs').setup({ ensure_installed = { 'go' }, highlight = { enable = true }, }) end, build = ':TSUpdate', }, { 'neovim/nvim-lspconfig' }, { 'ray-x/go.nvim', dev = (plugin_folder() ~= ''), -- dev = true, ft = 'go', dependencies = { 'mfussenegger/nvim-dap', -- Debug Adapter Protocol 'rcarriga/nvim-dap-ui', 'theHamsta/nvim-dap-virtual-text', 'ray-x/guihua.lua', }, config = true, opts = { verbose = true, max_line_len = 120, lsp_cfg = { handlers = { ['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'double' }), ['textDocument/signatureHelp'] = vim.lsp.with( vim.lsp.handlers.signature_help, { border = 'round' } ), }, }, -- false: do nothing } }, } end local opts = { root = package_root, -- directory where plugins will be installed default = { lazy = true }, dev = { -- directory where you store your local plugin projects path = plugin_folder(), }, } local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {}) vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*.go", callback = function() require('go.format').goimport() end, group = format_sync_grp, }) require('lazy').setup(load_plugins(), opts) vim.cmd('colorscheme murphy') ```Summary:
If I want to use
gofumpt
,goimports
, thengolines
doesn't work. (case 2) If I usegofumpt
andgolines
, then I cann't usegoimports
. (case 1) Would there be a way to make these commands works together when I save the file?