Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Jint-lzxy <[email protected]>
  • Loading branch information
Jint-lzxy committed Jun 12, 2024
1 parent a2824b8 commit c78f56e
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 44 deletions.
14 changes: 6 additions & 8 deletions lua/core/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local autocmd = {}

-- auto close NvimTree
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("NvimTreeClose", { clear = true }),
group = vim.api.nvim_create_augroup("NvimTreeAutoClose", { clear = true }),
pattern = "NvimTree_*",
callback = function()
local layout = vim.api.nvim_call_function("winlayout", {})
Expand Down Expand Up @@ -61,7 +61,7 @@ function autocmd.load_autocmds()
-- { "BufEnter", "*", "silent! lcd %:p:h" },
},
wins = {
-- Highlight current line only on focused window
-- Highlight current line only in focused window
{
"WinEnter,BufEnter,InsertLeave",
"*",
Expand All @@ -78,9 +78,9 @@ function autocmd.load_autocmds()
"*",
[[if has('nvim') | wshada | else | wviminfo! | endif]],
},
-- Check if file changed when its window is focus, more eager than 'autoread'
-- Check if a file has changed when its window is in focus, being more proactive than 'autoread'.
{ "FocusGained", "*", "checktime" },
-- Equalize window dimensions when resizing vim window
-- Maintain uniform window dimensions when resizing Vim windows
{ "VimResized", "*", [[tabdo wincmd =]] },
},
ft = {
Expand All @@ -91,14 +91,12 @@ function autocmd.load_autocmds()
{
"FileType",
"c,cpp",
"nnoremap <silent> <buffer> <leader>h :ClangdSwitchSourceHeader<CR>",
"nnoremap <silent> <buffer> <leader>h <Cmd>ClangdSwitchSourceHeader<CR>",
},
{
"FileType",
"cmake",
"nnoremap <silent> <nowait> <buffer> K <Cmd>lua vim.lsp.buf.hover()<CR>"
.. "|"
.. "lua vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'single' })",
"nnoremap <silent> <nowait> <buffer> K <Cmd>lua vim.lsp.buf.hover()<CR>",
},
},
yank = {
Expand Down
12 changes: 6 additions & 6 deletions lua/core/mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local core_map = {
["n|æ"] = map_cr("resize +2"):with_silent(),
["n|<C-q>"] = map_cr("wq"),
["n|Œ"] = map_cr("q!"),
["n|<leader>c"] = map_cr("setlocal spell! spelllang=en_us"),
["n|<leader>c"] = map_cr("setlocal spell! spelllang=en_us"):with_noremap(),
["x|<leader>p"] = map_cmd('"_dP'):with_silent():with_noremap(),
["n|+"] = map_cmd("<C-a>"):with_noremap():with_silent(),
["n|-"] = map_cmd("<C-x>"):with_noremap():with_silent(),
Expand Down Expand Up @@ -59,16 +59,16 @@ local core_map = {
["c|<C-h>"] = map_cmd("<BS>"):with_noremap(),
["c|<C-t>"] = map_cmd([[<C-R>=expand("%:p:h") . "/" <CR>]]):with_noremap(),
-- Visual mode
["v|J"] = map_cmd(":m '>+1<CR>gv=gv"),
["v|K"] = map_cmd(":m '<-2<CR>gv=gv"),
["v|<"] = map_cmd("<gv"),
["v|>"] = map_cmd(">gv"),
["v|J"] = map_cmd(":m '>+1<CR>gv=gv"):with_silent(),
["v|K"] = map_cmd(":m '<-2<CR>gv=gv"):with_silent(),
["v|<"] = map_cmd("<gv"):with_silent(),
["v|>"] = map_cmd(">gv"):with_silent(),
-- Accoustomed Settings
["n|<Up>"] = map_cr("resize +1"):with_silent():with_noremap(),
["n|<Down>"] = map_cr("resize -1"):with_silent():with_noremap(),
["n|<Left>"] = map_cr("vertical resize +2"):with_silent():with_noremap(),
["n|<Right>"] = map_cr("vertical resize -2"):with_silent():with_noremap(),
["n|ø"] = map_cmd("<Esc><C-w>q"),
["n|ø"] = map_cmd("<Esc><C-w>q"):with_noremap():with_noremap(),
}

bind.nvim_load_mapping(core_map)
4 changes: 2 additions & 2 deletions lua/core/settings.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local settings = {}

-- Set it to false if you want to use https to update plugins and treesitter parsers.
-- Set it to false if you want to use HTTPS to update plugins and treesitter parsers.
---@type boolean
settings["use_ssh"] = true

Expand Down Expand Up @@ -29,7 +29,7 @@ settings["format_disabled_dirs"] = {
}

-- Set it to false if diagnostics virtual text is annoying.
-- If disabled, you may browse lsp diagnostics using trouble.nvim (press `gt` to toggle it).
-- If disabled, you may browse lsp diagnostics using trouble.nvim (press `<leader>ld` to toggle it).
---@type boolean
settings["diagnostics_virtual_text"] = true

Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/completion/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ if vim.fn.executable("dart") == 1 then
nvim_lsp.dartls.setup(final_opts)
end

vim.api.nvim_command([[LspStart]]) -- Start LSPs
pcall(vim.cmd.LspStart) -- Start LSPs
4 changes: 2 additions & 2 deletions lua/modules/configs/completion/servers/html.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ return {
configurationSection = { "html", "css", "javascript" },
embeddedLanguages = { css = true, javascript = true },
},
settings = {},
single_file_support = true,
flags = { debounce_text_changes = 500 },
single_file_support = true,
settings = {},
}
4 changes: 2 additions & 2 deletions lua/modules/configs/editor/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ return vim.schedule_wrap(function()
require("nvim-treesitter.install").prefer_git = true
if use_ssh then
local parsers = require("nvim-treesitter.parsers").get_parser_configs()
for _, p in pairs(parsers) do
p.install_info.url = p.install_info.url:gsub("https://github.com/", "[email protected]:")
for _, parser in pairs(parsers) do
parser.install_info.url = parser.install_info.url:gsub("https://github.com/", "[email protected]:")
end
end
end)
39 changes: 20 additions & 19 deletions lua/modules/configs/lang/crates-keymap.lua
Original file line number Diff line number Diff line change
@@ -1,120 +1,121 @@
local bind = require("keymap.bind")
local map_callback = bind.map_callback

local crates = require("crates")
local crates_keymap = {
["n|<leader>ct"] = map_callback(function()
require("crates").toggle()
crates.toggle()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Toggle spec activities"),
["n|<leader>cr"] = map_callback(function()
require("crates").reload()
crates.reload()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Reload crate specs"),

["n|<leader>cs"] = map_callback(function()
require("crates").show_popup()
crates.show_popup()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Toggle pop-up window"),
["n|<leader>cv"] = map_callback(function()
require("crates").show_versions_popup()
require("crates").show_popup()
crates.show_versions_popup()
crates.show_popup()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Select spec versions"),
["n|<leader>cf"] = map_callback(function()
require("crates").show_features_popup()
require("crates").show_popup()
crates.show_features_popup()
crates.show_popup()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Select spec features"),
["n|<leader>cd"] = map_callback(function()
require("crates").show_dependencies_popup()
require("crates").show_popup()
crates.show_dependencies_popup()
crates.show_popup()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Show project dependencies"),

["n|<leader>cu"] = map_callback(function()
require("crates").update_crate()
crates.update_crate()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Update current crate's spec"),
["v|<leader>cu"] = map_callback(function()
require("crates").update_crates()
crates.update_crates()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Update selected crate's spec"),
["n|<leader>ca"] = map_callback(function()
require("crates").update_all_crates()
crates.update_all_crates()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Update all crates' specs"),
["n|<leader>cU"] = map_callback(function()
require("crates").upgrade_crate()
crates.upgrade_crate()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Upgrade current crate"),
["v|<leader>cU"] = map_callback(function()
require("crates").upgrade_crates()
crates.upgrade_crates()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Upgrade selected crates"),
["n|<leader>cA"] = map_callback(function()
require("crates").upgrade_all_crates()
crates.upgrade_all_crates()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Upgrade all crates"),

["n|<leader>cH"] = map_callback(function()
require("crates").open_homepage()
crates.open_homepage()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Open current crate's homepage"),
["n|<leader>cR"] = map_callback(function()
require("crates").open_repository()
crates.open_repository()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Open current crate's repository"),
["n|<leader>cD"] = map_callback(function()
require("crates").open_documentation()
crates.open_documentation()
end)
:with_noremap()
:with_silent()
:with_buffer(0)
:with_desc("crates: Open current crate's documentation"),
["n|<leader>cC"] = map_callback(function()
require("crates").open_crates_io()
crates.open_crates_io()
end)
:with_noremap()
:with_silent()
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/tool/which-key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ return function()
})

require("which-key").register({
-- <leader> stuffs
-- <leader> stuff
["<leader>"] = {
b = {
name = "󰓩 Buffers",
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/ui/bufferline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ return function()
filetype = "Outline",
text = "Symbol Outline",
text_align = "center",
padding = 0,
separator = true,
},
},
right_trunc_marker = icons.ui.Right,
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/plugins/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ editor["smoka7/hop.nvim"] = {
}
editor["tzachar/local-highlight.nvim"] = {
lazy = true,
event = { "BufNewFile", "BufReadPost", "BufFilePost" },
event = { "BufReadPost", "BufAdd", "BufNewFile" },
config = require("editor.localhl"),
}
editor["echasnovski/mini.align"] = {
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/plugins/lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lang["ray-x/go.nvim"] = {
lang["mrcjkb/rustaceanvim"] = {
lazy = true,
ft = "rust",
version = "^4",
version = "*",
init = require("lang.rust"),
dependencies = "nvim-lua/plenary.nvim",
}
Expand Down

0 comments on commit c78f56e

Please sign in to comment.