Skip to content

Commit

Permalink
feat(format): change format style
Browse files Browse the repository at this point in the history
  • Loading branch information
liubang committed Oct 22, 2023
1 parent 2bd4aad commit 0b14933
Show file tree
Hide file tree
Showing 24 changed files with 880 additions and 838 deletions.
72 changes: 36 additions & 36 deletions lua/lb/autocmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,51 @@
--
--=====================================================================

local filetype_commands_group = vim.api.nvim_create_augroup("FILETYPE_COMMANDS", { clear = true })
local filetype_commands_group = vim.api.nvim_create_augroup('FILETYPE_COMMANDS', { clear = true })

-- close lspinfo popup and help,qf buffers with q {{{
vim.api.nvim_create_autocmd("FileType", {
group = filetype_commands_group,
pattern = { "lspinfo", "lsp-installer", "null-ls-info", "help", "qf" },
callback = function()
local opts = { buffer = true, silent = true, desc = "close lspinfo popup and help,qf buffers" }
vim.keymap.set("n", "q", function()
vim.cmd.close()
end, opts)
end,
desc = "close lspinfo popup and help,qf buffers with q",
vim.api.nvim_create_autocmd('FileType', {
group = filetype_commands_group,
pattern = { 'lspinfo', 'lsp-installer', 'null-ls-info', 'help', 'qf' },
callback = function()
local opts = { buffer = true, silent = true, desc = 'close lspinfo popup and help,qf buffers' }
vim.keymap.set('n', 'q', function()
vim.cmd.close()
end, opts)
end,
desc = 'close lspinfo popup and help,qf buffers with q',
}) -- }}}

local special_settings_group = vim.api.nvim_create_augroup("SPECIAL_SETTINGS", { clear = true })
local special_settings_group = vim.api.nvim_create_augroup('SPECIAL_SETTINGS', { clear = true })

-- create missing parent directories automatically {{{
vim.api.nvim_create_autocmd("BufNewFile", {
group = special_settings_group,
callback = function()
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = 0,
once = true,
callback = function()
local path = vim.fn.expand "%:h"
local p = require("plenary.path"):new(path)
if not p:exists() then
p:mkdir { parents = true }
end
end,
desc = "create missing parent directories automatically",
})
end,
vim.api.nvim_create_autocmd('BufNewFile', {
group = special_settings_group,
callback = function()
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = 0,
once = true,
callback = function()
local path = vim.fn.expand '%:h'
local p = require('plenary.path'):new(path)
if not p:exists() then
p:mkdir { parents = true }
end
end,
desc = 'create missing parent directories automatically',
})
end,
}) -- }}}

-- go to last loc when opening a buffer {{{
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
vim.api.nvim_create_autocmd('BufReadPost', {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
}) -- }}}

-- vim: fdm=marker fdl=0
56 changes: 28 additions & 28 deletions lua/lb/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,56 @@
--
-- =====================================================================

vim.api.nvim_create_user_command("Filepath", function() -- {{{
---@diagnostic disable-next-line: param-type-mismatch
vim.notify(vim.fn.expand "%:p", vim.log.levels.INFO, {
title = "Filename",
timeout = 3000,
})
vim.api.nvim_create_user_command('Filepath', function() -- {{{
---@diagnostic disable-next-line: param-type-mismatch
vim.notify(vim.fn.expand '%:p', vim.log.levels.INFO, {
title = 'Filename',
timeout = 3000,
})
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("YankFilename", function() -- {{{
vim.fn.setreg('"', vim.fn.expand "%:t")
vim.api.nvim_create_user_command('YankFilename', function() -- {{{
vim.fn.setreg('"', vim.fn.expand '%:t')
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("YankFilepath", function() -- {{{
vim.fn.setreg('"', vim.fn.expand "%:p")
vim.api.nvim_create_user_command('YankFilepath', function() -- {{{
vim.fn.setreg('"', vim.fn.expand '%:p')
end, { nargs = 0 }) -- }}}

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

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

vim.api.nvim_create_user_command("TrimWhiteSpace", function() -- {{{
require("lb.utils.util").trim_whitespace()
vim.api.nvim_create_user_command('TrimWhiteSpace', function() -- {{{
require('lb.utils.util').trim_whitespace()
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("P", function(obj) -- {{{
vim.pretty_print(vim.fn.luaeval(obj.args))
vim.api.nvim_create_user_command('P', function(obj) -- {{{
vim.pretty_print(vim.fn.luaeval(obj.args))
end, { nargs = 1 }) -- }}}

vim.api.nvim_create_user_command("DocUpdate", function() -- {{{
require("lb.utils.doc").update()
vim.api.nvim_create_user_command('DocUpdate', function() -- {{{
require('lb.utils.doc').update()
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("Tasks", function() -- {{{
require("telescope").extensions.tasks.tasks()
vim.api.nvim_create_user_command('Tasks', function() -- {{{
require('telescope').extensions.tasks.tasks()
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("BazelBuild", function() -- {{{
require("telescope").extensions.bazel.bazel_build()
vim.api.nvim_create_user_command('BazelBuild', function() -- {{{
require('telescope').extensions.bazel.bazel_build()
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("BazelRun", function() -- {{{
require("telescope").extensions.bazel.bazel_run()
vim.api.nvim_create_user_command('BazelRun', function() -- {{{
require('telescope').extensions.bazel.bazel_run()
end, { nargs = 0 }) -- }}}

vim.api.nvim_create_user_command("BazelTests", function() -- {{{
require("telescope").extensions.bazel.bazel_tests()
vim.api.nvim_create_user_command('BazelTests', function() -- {{{
require('telescope').extensions.bazel.bazel_tests()
end, { nargs = 0 }) -- }}}

-- vim: fdm=marker fdl=0
18 changes: 9 additions & 9 deletions lua/lb/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
--=====================================================================

local M = {}
local health = vim.health or require "health"
local health = vim.health or require 'health'

local check_executable = function(bin, name, advice) -- {{{
if vim.fn.executable(bin) == 0 then
health.error(string.format("Please install %s, %s", name, advice))
else
health.ok(string.format("%s is installed", name))
end
if vim.fn.executable(bin) == 0 then
health.error(string.format('Please install %s, %s', name, advice))
else
health.ok(string.format('%s is installed', name))
end
end -- }}}

M.check = function() -- {{{
health.start "Checking nvim configuration requirements"
check_executable("yarn", "yarn", "Refer to https://classic.yarnpkg.com/en/docs/install")
check_executable("rg", "ripgrep", "Refer to https://github.com/BurntSushi/ripgrep#installation")
health.start 'Checking nvim configuration requirements'
check_executable('yarn', 'yarn', 'Refer to https://classic.yarnpkg.com/en/docs/install')
check_executable('rg', 'ripgrep', 'Refer to https://github.com/BurntSushi/ripgrep#installation')
end -- }}}

return M
Expand Down
24 changes: 12 additions & 12 deletions lua/lb/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
--
--=====================================================================

vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

require "lb.options" -- global options
require "lb.lazy" -- plugins spec
require 'lb.options' -- global options
require 'lb.lazy' -- plugins spec

vim.api.nvim_create_autocmd("User", { -- {{{
group = vim.api.nvim_create_augroup("LazyVim", { clear = true }),
pattern = "VeryLazy",
callback = function()
require "lb.autocmd" -- events
require "lb.commands"
require "lb.mappings"
end,
vim.api.nvim_create_autocmd('User', { -- {{{
group = vim.api.nvim_create_augroup('LazyVim', { clear = true }),
pattern = 'VeryLazy',
callback = function()
require 'lb.autocmd' -- events
require 'lb.commands'
require 'lb.mappings'
end,
}) -- }}}

-- vim: fdm=marker fdl=0
120 changes: 60 additions & 60 deletions lua/lb/lazy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,72 @@
--
-- =====================================================================

local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
local lazypath = vim.fn.stdpath 'data' .. '/lazy/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",
lazypath,
}
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable',
lazypath,
}
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup {
spec = { import = "plugins" },
defaults = { lazy = true },
concurrency = 6,
install = {
missing = false,
colorscheme = { "gruvbox-material" },
},
dev = {
path = "~/workspace/vim",
patterns = { "liubang" },
fallback = true,
},
checker = {
enabled = false,
},
change_detection = {
enabled = false,
},
ui = { border = "single" },
performance = { -- {{{
cache = {
enabled = true,
require('lazy').setup {
spec = { import = 'plugins' },
defaults = { lazy = true },
concurrency = 6,
install = {
missing = false,
colorscheme = { 'gruvbox-material' },
},
reset_packpath = true,
rtp = {
reset = true,
disabled_plugins = {
"gzip",
"matchit",
"matchparen",
"netrwPlugin",
"rplugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
dev = {
path = '~/workspace/vim',
patterns = { 'liubang' },
fallback = true,
},
checker = {
enabled = false,
},
change_detection = {
enabled = false,
},
ui = { border = 'single' },
performance = { -- {{{
cache = {
enabled = true,
},
reset_packpath = true,
rtp = {
reset = true,
disabled_plugins = {
'gzip',
'matchit',
'matchparen',
'netrwPlugin',
'rplugin',
'tarPlugin',
'tohtml',
'tutor',
'zipPlugin',
},
},
}, -- }}}
-- lazy can generate helptags from the headings in markdown readme files,
-- so :help works even for plugins that don't have vim docs.
-- when the readme opens with :help it will be correctly displayed as markdown
readme = { -- {{{
root = vim.fn.stdpath 'state' .. '/lazy/readme',
files = { 'README.md' },
-- only generate markdown helptags for plugins that dont have docs
skip_if_doc_exists = true,
}, -- }}}
profiling = {
loader = false,
require = false,
},
}, -- }}}
-- lazy can generate helptags from the headings in markdown readme files,
-- so :help works even for plugins that don't have vim docs.
-- when the readme opens with :help it will be correctly displayed as markdown
readme = { -- {{{
root = vim.fn.stdpath "state" .. "/lazy/readme",
files = { "README.md" },
-- only generate markdown helptags for plugins that dont have docs
skip_if_doc_exists = true,
}, -- }}}
profiling = {
loader = false,
require = false,
},
}

-- vim: fdm=marker fdl=0
Loading

0 comments on commit 0b14933

Please sign in to comment.