init: public
This commit is contained in:
13
modules/coding/editor/neovim/nvim/lua/langs/go.lua
Normal file
13
modules/coding/editor/neovim/nvim/lua/langs/go.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
vim.api.nvim_create_augroup("Go", {})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = { "*.go" },
|
||||
desc = "auto format Go files",
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
-- vim.fn.system("go fmt " .. vim.fn.expand("%:p"))
|
||||
-- vim.fn.system("goimports -w " .. vim.fn.expand("%:p"))
|
||||
-- vim.cmd("edit")
|
||||
end,
|
||||
group = "Go",
|
||||
})
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
require("langs.go")
|
||||
-- require("langs.rust")
|
||||
require("langs.lualang")
|
||||
require("langs.nix")
|
||||
require("langs.markdown")
|
||||
35
modules/coding/editor/neovim/nvim/lua/langs/lualang.lua
Normal file
35
modules/coding/editor/neovim/nvim/lua/langs/lualang.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
vim.api.nvim_create_augroup("Lua", {})
|
||||
|
||||
local old = {}
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = { "*.lua" },
|
||||
desc = "auto lua file indent",
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
-- Tab width setting
|
||||
old.tabstop = opt.tabstop
|
||||
old.shiftwidth = opt.shiftwidth
|
||||
old.softtabstop = opt.softtabstop
|
||||
old.expandtab = opt.expandtab
|
||||
opt.tabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
opt.softtabstop = 2
|
||||
opt.expandtab = true
|
||||
opt.autoindent = true
|
||||
end,
|
||||
group = "Lua",
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufLeave", {
|
||||
pattern = { "*.lua" },
|
||||
desc = "auto lua file indent",
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
-- Tab width setting
|
||||
opt.tabstop = old.tabstop
|
||||
opt.shiftwidth = old.shiftwidth
|
||||
opt.softtabstop = old.softtabstop
|
||||
opt.expandtab = old.expandtab
|
||||
end,
|
||||
group = "Lua",
|
||||
})
|
||||
|
||||
35
modules/coding/editor/neovim/nvim/lua/langs/markdown.lua
Normal file
35
modules/coding/editor/neovim/nvim/lua/langs/markdown.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
vim.api.nvim_create_augroup("Markdown", {})
|
||||
|
||||
local old = {}
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = { "*.md" },
|
||||
desc = "auto md file indent",
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
-- Tab width setting
|
||||
old.tabstop = opt.tabstop
|
||||
old.shiftwidth = opt.shiftwidth
|
||||
old.softtabstop = opt.softtabstop
|
||||
old.expandtab = opt.expandtab
|
||||
opt.tabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
opt.softtabstop = 2
|
||||
opt.expandtab = true
|
||||
opt.autoindent = true
|
||||
end,
|
||||
group = "Markdown",
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufLeave", {
|
||||
pattern = { "*.md" },
|
||||
desc = "auto markdown file indent",
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
-- Tab width setting
|
||||
opt.tabstop = old.tabstop
|
||||
opt.shiftwidth = old.shiftwidth
|
||||
opt.softtabstop = old.softtabstop
|
||||
opt.expandtab = old.expandtab
|
||||
end,
|
||||
group = "Markdown",
|
||||
})
|
||||
|
||||
35
modules/coding/editor/neovim/nvim/lua/langs/nix.lua
Normal file
35
modules/coding/editor/neovim/nvim/lua/langs/nix.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
vim.api.nvim_create_augroup("Nix", {})
|
||||
|
||||
local old = {}
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = { "*.nix" },
|
||||
desc = "auto nix file indent",
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
-- Tab width setting
|
||||
old.tabstop = opt.tabstop
|
||||
old.shiftwidth = opt.shiftwidth
|
||||
old.softtabstop = opt.softtabstop
|
||||
old.expandtab = opt.expandtab
|
||||
opt.tabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
opt.softtabstop = 2
|
||||
opt.expandtab = true
|
||||
opt.autoindent = true
|
||||
end,
|
||||
group = "Nix",
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufLeave", {
|
||||
pattern = { "*.nix" },
|
||||
desc = "auto nix file indent",
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
-- Tab width setting
|
||||
opt.tabstop = old.tabstop
|
||||
opt.shiftwidth = old.shiftwidth
|
||||
opt.softtabstop = old.softtabstop
|
||||
opt.expandtab = old.expandtab
|
||||
end,
|
||||
group = "Nix",
|
||||
})
|
||||
|
||||
11
modules/coding/editor/neovim/nvim/lua/langs/rust.lua
Normal file
11
modules/coding/editor/neovim/nvim/lua/langs/rust.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
vim.api.nvim_create_augroup("Rust", {})
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = { "*.rs" },
|
||||
desc = "auto format Rust files",
|
||||
callback = function()
|
||||
vim.fn.system("rustfmt " .. vim.fn.expand("%:p"))
|
||||
vim.cmd("edit")
|
||||
end,
|
||||
group = "Rust",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user