Skip to content

Commit

Permalink
perf(mix): some opts
Browse files Browse the repository at this point in the history
  • Loading branch information
liubang committed Dec 3, 2023
1 parent b66af43 commit 3a63077
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 97 deletions.
6 changes: 3 additions & 3 deletions lua/lb/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ vim.api.nvim_create_user_command("YankFilepath", function() -- {{{
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("CopyRight", function() -- {{{
require("lb.utils.comment").copy_right("liubang")
require("lb.utils.comment").copy_right()
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("CopyRightUpdate", function() -- {{{
require("lb.utils.comment").copy_right_update()
vim.api.nvim_create_user_command("CopyRightApache", function() -- {{{
require("lb.utils.comment").copy_right_apache()
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("TrimWhiteSpace", function() -- {{{
Expand Down
49 changes: 42 additions & 7 deletions lua/lb/utils/comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@
--
-- =====================================================================

local M = {}

M.opts = {
author = "liubang",
email = "[email protected]",
}

function M.setup(opts)
if opts.author then
M.opts.author = opts.author
end
if opts.email then
M.opts.email = opts.email
end
end

-- stylua: ignore
local prefix_mappings = { -- {{{
["c"] = "//",
Expand Down Expand Up @@ -56,7 +72,7 @@ local comment_line = function(c, r) -- {{{
return prefix
end -- }}}

local copy_right = function(author) -- {{{
function M.copy_right() -- {{{
local c = comment_prefix()
local complete = comment_line("=", 71)
local filename = vim.fn.expand("%:t")
Expand All @@ -72,14 +88,14 @@ local copy_right = function(author) -- {{{
table.insert(text, c)
table.insert(text, c .. " " .. filename .. " -")
table.insert(text, c)
table.insert(text, c .. " Created by " .. author .. " on " .. t)
table.insert(text, c .. " Created by " .. M.opts.author .. " on " .. t)
table.insert(text, c .. " Last Modified: " .. t)
table.insert(text, c)
table.insert(text, complete)
vim.fn.append(0, text)
end -- }}}

local copy_right_update = function() -- {{{
function M.copy_right_update() -- {{{
local pos = vim.api.nvim_win_get_cursor(0)
local n = math.min(10, vim.fn.line("$"))
local timestamp = os.date("%Y/%m/%d %H:%M")
Expand All @@ -89,9 +105,28 @@ local copy_right_update = function() -- {{{
vim.cmd([[let @/=""]])
end -- }}}

return { -- {{{
copy_right = copy_right,
copy_right_update = copy_right_update,
} -- }}}
function M.copy_right_apache()
local c = comment_prefix()
local text = {}
table.insert(text, c .. " Copyright (c) " .. os.date("%Y") .. " The Authors. All rights reserved.")
table.insert(text, c)
table.insert(text, c .. ' Licensed under the Apache License, Version 2.0 (the "License");')
table.insert(text, c .. " you may not use this file except in compliance with the License.")
table.insert(text, c .. " You may obtain a copy of the License at")
table.insert(text, c)
table.insert(text, c .. " https://www.apache.org/licenses/LICENSE-2.0")
table.insert(text, c)
table.insert(text, c .. " Unless required by applicable law or agreed to in writing, software")
table.insert(text, c .. ' distributed under the License is distributed on an "AS IS" BASIS,')
table.insert(text, c .. " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.")
table.insert(text, c .. " See the License for the specific language governing permissions and")
table.insert(text, c .. " limitations under the License.")
table.insert(text, "")
table.insert(text, string.format("%s Authors: %s (%s)", c, M.opts.author, M.opts.email))
table.insert(text, "")
vim.fn.append(0, text)
end

return M

-- vim: fdm=marker fdl=0
1 change: 0 additions & 1 deletion lua/plugins/aerial-nvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

return {
"stevearc/aerial.nvim", -- {{{
branch = "master",
cmd = "AerialToggle",
opts = {
backends = { "lsp", "markdown" },
Expand Down
16 changes: 16 additions & 0 deletions lua/plugins/neogen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--=====================================================================
--
-- neogen.lua -
--
-- Created by liubang on 2023/12/03 16:03
-- Last Modified: 2023/12/03 16:03
--
--=====================================================================

return {
"danymat/neogen",
cmd = "Neogen",
opts = {
snippet_engine = "luasnip",
},
}
12 changes: 6 additions & 6 deletions lua/plugins/nvim-navic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ return {
})
end,
opts = function()
-- stylua: ignore
return {
-- stylua: ignore
icons = require('lb.config').kinds,
separator = " > ",
depth_limit = 3,
highlight = true,
icons = require('lb.config').kinds,
separator = " > ",
depth_limit = 3,
highlight = true,
depth_limit_indicator = "..",
safe_output = true,
safe_output = true,
}
end,
-- }}}
Expand Down
55 changes: 0 additions & 55 deletions lua/plugins/smart-split-nvim.lua

This file was deleted.

4 changes: 1 addition & 3 deletions lua/plugins/snips/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ return {
config = function(_, opts)
require("luasnip").setup(opts)
require("plugins.snips.all")
require("luasnip.loaders.from_vscode").lazy_load({
exclude = { "javascript" },
})
require("luasnip.loaders.from_vscode").lazy_load()
end,
}

Expand Down
2 changes: 2 additions & 0 deletions lua/plugins/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local M = {
dependencies = {
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
{ "nvim-telescope/telescope-ui-select.nvim" },
{ "debugloop/telescope-undo.nvim" },
{ "skywind3000/asynctasks.vim" },
},
keys = {
Expand Down Expand Up @@ -136,6 +137,7 @@ function M.config()
telescope.load_extension("fzf")
telescope.load_extension("bazel")
telescope.load_extension("tasks")
telescope.load_extension("undo")

local colors = { --{{{
white = "#ebdbb2",
Expand Down
22 changes: 0 additions & 22 deletions lua/plugins/undotree.lua

This file was deleted.

0 comments on commit 3a63077

Please sign in to comment.