Skip to content

Commit

Permalink
feat: add stickybuf, update .clang-format, use hop for search zh
Browse files Browse the repository at this point in the history
  • Loading branch information
fcying committed Nov 8, 2024
1 parent 915bab5 commit 12416c2
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 52 deletions.
54 changes: 29 additions & 25 deletions etc/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,41 @@ UseTab: Never
AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AlignArrayOfStructures: Right
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
# AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
SkipMacroDefinitionBody: true
SeparateDefinitionBlocks: Leave

BreakBeforeBraces: Allman # Allman Linux
AccessModifierOffset: -4
AlwaysBreakBeforeMultilineStrings: false
AllowShortIfStatementsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: Never
AlignEscapedNewlines: Left
BinPackArguments: true
BinPackParameters: true
CommentPragmas: '^ IWYU pragma:'
IndentCaseLabels: false
PointerAlignment: Right
SortIncludes: Never
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
3 changes: 2 additions & 1 deletion etc/zsh_plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ alias glgp='git log --stat -p'
alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glo="git log --graph --pretty='%Cred%h%Creset %C(auto)%d%Creset %s %Cgreen(%ai) %C(bold blue)<%an>%Creset'"
alias glo="git log --graph --pretty='%Cred%h%Creset %C(auto)%d%Creset %s %Cgreen(%ai) %C(bold blue)<%an>%Creset'"
alias glos="git log --graph --pretty='%Cred%h%Creset %C(auto)%d%Creset %s %Cgreen(%ai) %C(bold blue)<%an>%Creset' --stat"
alias gloa="git log --graph --pretty='%Cred%h%Creset %C(auto)%d%Creset %s %Cgreen(%ai) %C(bold blue)<%an>%Creset' --all"
alias glS='git log --source -S'
compdef _git glp=git-log

alias gm='git merge'
Expand Down
6 changes: 4 additions & 2 deletions lua/_lazy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ local plugins = {
-- { import = "plugins.vim-visual-multi" },
{ import = "plugins.multicursor" },
{ import = "plugins.vim_expand_region" },
{ import = "plugins.flash" },
-- { import = "plugins.flash" },
{ import = "plugins.hop" },
{ import = "plugins.foldsearch" },
{ import = "plugins.lualine" },

Expand All @@ -55,6 +56,7 @@ local plugins = {
require("plugins.asynctasks").setup,
-- { import = "plugins.overseer" },
{ import = "plugins.whichkey" },
{ import = "plugins.stickybuf" },

-- filetype {{{
--{ 'kevinhwang91/nvim-bqf', ft = 'qf' },
Expand All @@ -70,7 +72,7 @@ local plugins = {
{ import = "plugins.lazydev" },
{ import = vim.g.complete_engine == "blink" and "plugins.blink" or "plugins.cmp" },
{ import = "plugins.treesitter" },
{ import = "plugins.tiny_inline_diagnostic" },
-- { import = "plugins.tiny_inline_diagnostic" },
{
"neovim/nvim-lspconfig",
cmd = { "LspInfo", "LspInstall", "LspStart", "LspRestart" },
Expand Down
19 changes: 15 additions & 4 deletions lua/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Formats = {
"--pad-oper", "--pad-header",
"--align-pointer=name", "--align-reference=name",
},
["clang-format"] = {
-- "--style=file:" .. vim.g.config_dir .. "/etc/.clang-format",
},
}

local diagnostics_on = true
Expand Down Expand Up @@ -51,7 +54,7 @@ local function diagnostics_config(enable)
end

function M.format()
require("conform").format({ timeout_ms = 5000 })
require("conform").format()
end

function M.null_ls()
Expand Down Expand Up @@ -283,11 +286,9 @@ end

function M.setup()
--lsp.set_log_level('debug')

api.nvim_create_user_command("Format", function() require("lsp").format() end, {})

vim.diagnostic.config({ virtual_text = false })

-- lsp_zero
local lsp_zero = require("lsp-zero")
local lsp_attach = function(client, bufnr) ---@diagnostic disable-line
local opts = { buffer = bufnr }
Expand Down Expand Up @@ -326,6 +327,16 @@ function M.setup()
set()
end

-- diagnostic
vim.diagnostic.config({
virtual_text = false,
float = {
border = "rounded",
source = false,
}
})


local lspconfig = require("lspconfig")
local mason_server = require("mason-lspconfig.mappings.server")
mason_server.package_to_lspconfig["autohotkey2-lsp"] = "autohotkey2-lsp"
Expand Down
30 changes: 15 additions & 15 deletions lua/plugins/blink.lua
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
---@module 'blink.cmp'
---@type blink.cmp.Config
local opts = {
highlight = {
use_nvim_cmp_as_default = true,
},
nerd_font_variant = "normal",
keymap = {
preset = "enter",
["<C-l>"] = { "show", "show_documentation", "hide_documentation" },
["<C-e>"] = { "hide" },
["<CR>"] = { "select_and_accept" },

["<Up>"] = { "select_prev", "fallback" },
["<Down>"] = { "select_next", "fallback" },
["<C-p>"] = { "select_prev", "fallback" },
["<C-n>"] = { "select_next", "fallback" },
["<C-space>"] = { "fallback" },
["<S-Tab>"] = { "select_prev", "snippet_backward", "fallback" },
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },

["<C-b>"] = { "scroll_documentation_up", "fallback" },
["<C-f>"] = { "scroll_documentation_down", "fallback" },
},
sources = {
completion = {
enabled_providers = { "lsp", "path", "snippets", "buffer", "dictionary" },
enabled_providers = { "lsp", "path", "snippets", "buffer", "lazydev", "dictionary" },
},
providers = {
lsp = {
min_keyword_length = 2,
-- dont show LuaLS require statements when lazydev has items
fallback_for = { "lazydev" },
},
lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" },
snippets = {
name = "Snippets",
module = "blink.cmp.sources.snippets",
score_offset = -3,
min_keyword_length = 2,
opts = {
friendly_snippets = true,
search_paths = { vim.g.config_dir .. "/snippets" },
Expand All @@ -35,21 +36,20 @@ local opts = {
ignored_filetypes = {},
},
},
buffer = { min_keyword_length = 2, },
dictionary = {
name = "dictionary",
module = "blink.compat.source",
score_offset = 3,
opts = {
{ name = "dictionary" },
}
min_keyword_length = 2,
},
},
},
}

return {
"saghen/blink.cmp",
lazy = false,
event = { "InsertEnter", "CmdlineEnter" },
dependencies = {
"rafamadriz/friendly-snippets",
{ "saghen/blink.compat", opts = { impersontate_nvim_cmp = true, } },
Expand Down
23 changes: 20 additions & 3 deletions lua/plugins/conform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,35 @@ return {
config = function()
require("conform").setup({
default_format_opts = {
lsp_format = "fallback",
timeout_ms = 5000,
lsp_format = "fallback", -- fallback never
},
-- format_after_save = {
-- timeout_ms = 5000,
-- lsp_format = "fallback",
-- },
notify_on_error = true,
formatters_by_ft = {
-- c = { "astyle" },
-- cpp = { "astyle" },
-- lua = { "stylua" },
c = { "clang-format" },
cpp = { "clang-format" },
},
formatters = {
stylua = {
inherit = false,
command = "stylua",
args = Formats.stylua,
},
astyle = {
inherit = false,
command = "astyle",
args = Formats.astyle,
},
["clang-format"] = {
inherit = false,
command = "clang-format",
args = Formats["clang-format"],
},
},
})
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
Expand Down
23 changes: 23 additions & 0 deletions lua/plugins/hop.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
return {
"smoka7/hop.nvim",
version = "*",
keys = {
{
"s",
mode = { "n" },
function()
local hop = require("hop")
-- local directions = require("hop.hint").HintDirection
-- hop.hint_char1({ direction = directions.AFTER_CURSOR })
hop.hint_char1({})
end,
desc = "hop"
},
},
config = function()
require("hop").setup({
keys = "etovxqpdygfblzhckisuran",
match_mappings = { "zh", "zh_sc" },
})
end,
}
17 changes: 15 additions & 2 deletions lua/plugins/mini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ return {
keys = { { "<leader>q", function() require("mini.bufremove").delete() end, desc = "Quit Buffer" } },
config = function()
require("mini.bufremove").setup()
-- api.nvim_create_user_command("Bclose", "Bdelete", { bang = true })
end
},
{
"echasnovski/mini.surround",
opts = {},
keys = { "<leader>s" },
opts = {
mappings = {
add = "<leader>sa", -- Add surrounding in Normal and Visual modes
delete = "<leader>sd", -- Delete surrounding
find = "<leader>sf", -- Find surrounding (to the right)
find_left = "<leader>sF", -- Find surrounding (to the left)
highlight = "<leader>sh", -- Highlight surrounding
replace = "<leader>sr", -- Replace surrounding
update_n_lines = "<leader>sn", -- Update `n_lines`

suffix_last = "l", -- Suffix to search with "prev" method
suffix_next = "n", -- Suffix to search with "next" method
},
},
},
}
6 changes: 6 additions & 0 deletions lua/plugins/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ return {
}
end
},
-- {
-- "karb94/neoscroll.nvim",
-- config = function()
-- require("neoscroll").setup({})
-- end
-- },
--{ 'simnalamburt/vim-mundo', event = 'VimEnter' },
}
4 changes: 4 additions & 0 deletions lua/plugins/stickybuf.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
"stevearc/stickybuf.nvim",
opts = {},
}
1 change: 1 addition & 0 deletions lua/plugins/whichkey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ return {
{ "<leader>m", group = "mark" },
{ "<leader>s", group = "sandwich" },
{ "<leader>p", group = "plugin" },
{ "<leader>s", group = "surround" },
{ "<leader>t", group = "tab" },
{ "<leader>u", group = "util" },
{ "<leader>w", group = "window" },
Expand Down

0 comments on commit 12416c2

Please sign in to comment.