diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-02-28 23:13:39 +0800 | 
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-02-28 23:13:39 +0800 | 
| commit | a0f2f7e29035553562941f4046db88d707daf199 (patch) | |
| tree | b6b56019f89a2f3b1a6cffccba2849687ee61241 /configs/nvim/config-root/lua | |
| parent | 346b5256b99e28cd5c67c03dca4be84e1c75f749 (diff) | |
| download | crupest-a0f2f7e29035553562941f4046db88d707daf199.tar.gz crupest-a0f2f7e29035553562941f4046db88d707daf199.tar.bz2 crupest-a0f2f7e29035553562941f4046db88d707daf199.zip  | |
chore(store): move everything to store.
Diffstat (limited to 'configs/nvim/config-root/lua')
14 files changed, 0 insertions, 527 deletions
diff --git a/configs/nvim/config-root/lua/crupest/nvim/keymap.lua b/configs/nvim/config-root/lua/crupest/nvim/keymap.lua deleted file mode 100644 index 624c04c..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/keymap.lua +++ /dev/null @@ -1,9 +0,0 @@ -local function setup() -    vim.keymap.set("n", "<c-tab>", "<cmd>bnext<cr>") -    vim.keymap.set("n", "<c-s-tab>", "<cmd>bNext<cr>") -    vim.keymap.set("n", "<esc>", require("crupest.utils.nvim").close_float) -end - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/lsp/c.lua b/configs/nvim/config-root/lua/crupest/nvim/lsp/c.lua deleted file mode 100644 index bb1f6f7..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/lsp/c.lua +++ /dev/null @@ -1,25 +0,0 @@ -local lspconfig = require("lspconfig") - -local brew_clangd_path = "/usr/local/opt/llvm/bin/clangd" - -local function setup() -    local clangd = "clangd" - -    if vim.uv.fs_stat(brew_clangd_path) ~= nil then -        clangd = brew_clangd_path -    end - -    -- setup lsp clangd -    lspconfig.clangd.setup { -        cmd = { clangd }, -        on_attach = function(_, bufnr) -            vim.keymap.set('n', '<space>s', "<cmd>ClangdSwitchSourceHeader<cr>", { -                buffer = bufnr -            }) -        end -    } -end - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/lsp/init.lua b/configs/nvim/config-root/lua/crupest/nvim/lsp/init.lua deleted file mode 100644 index 0fd29a3..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/lsp/init.lua +++ /dev/null @@ -1,50 +0,0 @@ -local lspconfig = require("lspconfig") -local cmp_nvim_lsp = require("cmp_nvim_lsp") -local cmp_default_caps = cmp_nvim_lsp.default_capabilities() - -local lspconfig_default_caps = lspconfig.util.default_config.capabilities - -lspconfig.util.default_config = vim.tbl_extend( -    "force", -    lspconfig.util.default_config, -    { -        capabilities = vim.tbl_extend("force",  lspconfig_default_caps, cmp_default_caps), -        autostart = false, -    }) - -local function setup() -    lspconfig.cmake.setup {} -    lspconfig.bashls.setup {} -    require("crupest.nvim.lsp.c").setup() -    require("crupest.nvim.lsp.lua").setup() - -    -- Use LspAttach auto command to only map the following keys -    -- after the language server attaches to the current buffer -    vim.api.nvim_create_autocmd('LspAttach', { -        group = vim.api.nvim_create_augroup('UserLspConfig', {}), -        callback = function(ev) -            -- Buffer local mappings. -            -- See `:help vim.lsp.*` for documentation on any of the below functions -            local opts = { buffer = ev.buf } -            vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) -            vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) -            vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) -            vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts) -            vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) -            vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) -            vim.keymap.set('n', '<space>wl', function() -                print(vim.inspect(vim.lsp.buf.list_workspace_folders())) -            end, opts) -            vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts) -            vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts) -            vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts) -            vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) -            vim.keymap.set('n', '<space>f', vim.lsp.buf.format, opts) -        end, -    }) -end - - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/lsp/lua.lua b/configs/nvim/config-root/lua/crupest/nvim/lsp/lua.lua deleted file mode 100644 index 93aa503..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/lsp/lua.lua +++ /dev/null @@ -1,29 +0,0 @@ -local lspconfig = require("lspconfig") - -local function setup() -    lspconfig.lua_ls.setup { -        settings = { -            Lua = { -                runtime = { -                    version = "LuaJIT" -                }, -                diagnostics = { -                    globals = { "vim" }, -                }, -                workspace = { -                    library = { -                        [vim.fn.expand "$VIMRUNTIME/lua"] = true, -                        [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, -                        [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, -                    }, -                    maxPreload = 100000, -                    preloadFileSize = 10000, -                }, -            }, -        }, -    } -end - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/cmp.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/cmp.lua deleted file mode 100644 index 9b1d876..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/plugins/cmp.lua +++ /dev/null @@ -1,31 +0,0 @@ -local function setup() -    local cmp = require("cmp") -    local luasnip = require("luasnip") - -    cmp.setup { -        snippet = { -            expand = function(args) -                luasnip.lsp_expand(args.body) -            end, -        }, -        window = { -        }, -        mapping = cmp.mapping.preset.insert({ -            ['<C-b>'] = cmp.mapping.scroll_docs(-4), -            ['<C-f>'] = cmp.mapping.scroll_docs(4), -            ['<C-Space>'] = cmp.mapping.complete(), -            ['<C-e>'] = cmp.mapping.abort(), -            ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. -        }), -        sources = cmp.config.sources({ -            { name = 'nvim_lsp' }, -            { name = 'luasnip' }, -        }, { -            { name = 'buffer' }, -        }) -    } -end - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/gitsigns.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/gitsigns.lua deleted file mode 100644 index 220c91a..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/plugins/gitsigns.lua +++ /dev/null @@ -1,51 +0,0 @@ -local function setup() -    local gitsigns = require('gitsigns') -    gitsigns.setup { -        on_attach = function(bufnr) -            local function map(mode, l, r, opts) -                opts = opts or {} -                opts.buffer = bufnr -                vim.keymap.set(mode, l, r, opts) -            end - -            -- Navigation -            map('n', ']c', function() -                if vim.wo.diff then -                    vim.cmd.normal({ ']c', bang = true }) -                else -                    gitsigns.nav_hunk('next') -                end -            end) - -            map('n', '[c', function() -                if vim.wo.diff then -                    vim.cmd.normal({ '[c', bang = true }) -                else -                    gitsigns.nav_hunk('prev') -                end -            end) - -            -- Actions -            map('n', '<leader>hs', gitsigns.stage_hunk) -            map('n', '<leader>hr', gitsigns.reset_hunk) -            map('v', '<leader>hs', function() gitsigns.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end) -            map('v', '<leader>hr', function() gitsigns.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end) -            map('n', '<leader>hS', gitsigns.stage_buffer) -            map('n', '<leader>hu', gitsigns.undo_stage_hunk) -            map('n', '<leader>hR', gitsigns.reset_buffer) -            map('n', '<leader>hp', gitsigns.preview_hunk) -            map('n', '<leader>hb', function() gitsigns.blame_line { full = true } end) -            map('n', '<leader>tb', gitsigns.toggle_current_line_blame) -            map('n', '<leader>hd', gitsigns.diffthis) -            map('n', '<leader>hD', function() gitsigns.diffthis('~') end) -            map('n', '<leader>td', gitsigns.toggle_deleted) - -            -- Text object -            map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>') -        end -    } -end - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/init.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/init.lua deleted file mode 100644 index 24e0c2e..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/plugins/init.lua +++ /dev/null @@ -1,12 +0,0 @@ -local function setup() -    require("crupest.nvim.plugins.lint").setup() -    require("crupest.nvim.plugins.snip").setup() -    require("crupest.nvim.plugins.cmp").setup() -    require("crupest.nvim.plugins.telescope").setup() -    require("crupest.nvim.plugins.gitsigns").setup() -    require("crupest.nvim.plugins.others").setup() -end - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/lint.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/lint.lua deleted file mode 100644 index 5e348d6..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/plugins/lint.lua +++ /dev/null @@ -1,82 +0,0 @@ -local lint = require("lint") - -local find = require('crupest.utils.find') -local is_win = vim.fn.has("win32") ~= 0 - -local cspell_config_patterns = { -    ".cspell.json", -    "cspell.json", -    ".cSpell.json", -    "cSpell.json", -    "cspell.config.js", -    "cspell.config.cjs", -    "cspell.config.json", -    "cspell.config.yaml", -    "cspell.config.yml", -    "cspell.yaml", -    "cspell.yml", -} - ---- @type FindExeForBufOpts[] -local my_linters = { -    { -        name = "cspell", -        places = { "node_modules", "global" }, -        config_files = cspell_config_patterns, -    }, -} - -local function run(opt) -    if not opt then -        opt = {} -    end - -    if not opt.buf then -        opt.buf = 0 -    end - -    local linters = {} - -    for _, l in ipairs(my_linters) do -        local linter = find.find_exe_for_buf(opt.buf, l) -        if linter then table.insert(linters, linter) end -    end - - -    local linter_names = {} - -    for _, linter in ipairs(linters) do -        table.insert(linter_names, linter.name) -        require('lint.linters.' .. linter.name).cmd = linter.exe_path -    end - -    lint.try_lint(linter_names) -end - -local function setup() -    if is_win then -        for _, l in ipairs(my_linters) do -            local name = l.name -            local linter = require('lint.linters.' .. name) -            if linter.cmd == 'cmd.exe' then -                linter.cmd = linter.args[2] -            end -            table.remove(linter.args, 1) -            table.remove(linter.args, 1) -        end -    end - -    vim.api.nvim_create_autocmd({ "BufWritePost" }, { -        callback = function(opt) -            run({ -                buf = opt.buffer -            }) -        end, -    }) - -    vim.keymap.set('n', '<leader>lr', run) -end - -return { -    setup = setup, -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/others.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/others.lua deleted file mode 100644 index 2ef0d75..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/plugins/others.lua +++ /dev/null @@ -1,9 +0,0 @@ -local function setup() -    require('lualine').setup {} -    require("nvim-tree").setup {} -    require("nvim-autopairs").setup {} -end - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/snip.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/snip.lua deleted file mode 100644 index 78ed2eb..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/plugins/snip.lua +++ /dev/null @@ -1,75 +0,0 @@ ---- spellchecker: disable - -local luasnip = require("luasnip") - -local ls = luasnip --- some shorthands... -local s = ls.snippet -local sn = ls.snippet_node -local t = ls.text_node -local i = ls.insert_node -local f = ls.function_node -local c = ls.choice_node -local d = ls.dynamic_node -local r = ls.restore_node -local l = require("luasnip.extras").lambda -local rep = require("luasnip.extras").rep -local p = require("luasnip.extras").partial -local m = require("luasnip.extras").match -local n = require("luasnip.extras").nonempty -local dl = require("luasnip.extras").dynamic_lambda -local fmt = require("luasnip.extras.fmt").fmt -local fmta = require("luasnip.extras.fmt").fmta -local types = require("luasnip.util.types") -local conds = require("luasnip.extras.conditions") -local conds_expand = require("luasnip.extras.conditions.expand") - -local function copy(args) -    return args[1] -end - -local function setup() -    vim.keymap.set({ "i", "s" }, "<C-L>", function() luasnip.jump(1) end, { silent = true }) -    vim.keymap.set({ "i", "s" }, "<C-J>", function() luasnip.jump(-1) end, { silent = true }) - -    vim.keymap.set({ "i", "s" }, "<C-E>", function() -        if luasnip.choice_active() then -            luasnip.change_choice(1) -        end -    end, { silent = true }) - -    luasnip.add_snippets("cpp", { -        s("cs", { -            i(1, "classname"), -            t("::"), -            f(copy, 1), -            t("("), -            i(0), -            t(") { }") -        }), - -        s("ds", { -            i(1, "classname"), -            t("::~"), -            f(copy, 1), -            t("() { }") -        }), - -        s("csds", { -            i(1, "classname"), -            t("::"), -            f(copy, 1), -            t("("), -            i(0), -            t({ ") { }", "", "" }), -            f(copy, 1), -            t("::~"), -            f(copy, 1), -            t("() { }") -        }), -    }) -end - -return { -    setup = setup, -} diff --git a/configs/nvim/config-root/lua/crupest/nvim/plugins/telescope.lua b/configs/nvim/config-root/lua/crupest/nvim/plugins/telescope.lua deleted file mode 100644 index d68b7f2..0000000 --- a/configs/nvim/config-root/lua/crupest/nvim/plugins/telescope.lua +++ /dev/null @@ -1,11 +0,0 @@ -local function setup() -    local builtin = require('telescope.builtin') -    vim.keymap.set('n', '<leader>ff', builtin.find_files, {}) -    vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) -    vim.keymap.set('n', '<leader>fb', builtin.buffers, {}) -    vim.keymap.set('n', '<leader>fh', builtin.help_tags, {}) -end - -return { -    setup = setup -} diff --git a/configs/nvim/config-root/lua/crupest/utils/find.lua b/configs/nvim/config-root/lua/crupest/utils/find.lua deleted file mode 100644 index dd1f663..0000000 --- a/configs/nvim/config-root/lua/crupest/utils/find.lua +++ /dev/null @@ -1,101 +0,0 @@ -local is_win = vim.fn.has("win32") ~= 0 - -local M = {} - -local windows_exe_ext = { "exe", "bat", "cmd", "ps1" } - ---- Find real path (with ext) for an executable. ---- @param dir string ---- @param name string | string[] ---- @return string | nil -function M.find_exe_file(dir, name) -    if type(name) == "string" then -        name = { name } -    end -    for _, n in ipairs(name) do -        if vim.uv.fs_stat(vim.fs.joinpath(dir, n)) ~= nil then -            return n -        end -        if is_win then -            for _, ext in ipairs(windows_exe_ext) do -                if vim.uv.fs_stat(vim.fs.joinpath(dir, n .. "." .. ext)) ~= nil then -                    return n .. "." .. ext -                end -            end -        end -    end -    return nil -end - ---- Walk up until found an executable in node_modules. ---- @param path string ---- @param name string ---- @return string | nil exe_path Path to the executable. -function M.find_node_modules_exe(path, name) -    local bin_dirs = vim.fs.find("node_modules/.bin", { path = path, upward = true, type = "directory" }) -    if #bin_dirs == 0 then return nil end -    local exe = M.find_exe_file(bin_dirs[1], name) -    return exe and vim.fs.joinpath(bin_dirs[1], exe) -end - ---- Find executable in PATH. ---- @param name string ---- @return string | nil -function M.find_global_exe(name) -    local exe = vim.fn.exepath(name) -    if exe == "" then return nil end -    return exe -end - ---- @alias ExePlace "node_modules" | "global" ---- @param path string ---- @param name string ---- @param places ExePlace[] ---- @return string | nil, ExePlace? -function M.find_exe(path, name, places) -    for _, place in ipairs(places) do -        if place == "node_modules" then -            local r = M.find_node_modules_exe(path, name) -            if r then return r, "node_modules" end -        end -        if place == "global" then -            local r = M.find_global_exe(name) -            if r then return r, "global" end -        end -    end -    return nil, nil -end - ---- @alias FindExeForBufOpts { name: string, exe: string?, places: ExePlace[], config_files: string[]?, filetypes: string[]? } ---- @alias FindExeForBufResult { name: string, file: string, exe: string, exe_path: string, place: ExePlace, config_file: string?, filetype: string? } ---- @param buf number ---- @param opts FindExeForBufOpts ---- @return FindExeForBufResult | nil -function M.find_exe_for_buf(buf, opts) -    local r = {} --- @type FindExeForBufResult -    r.name = opts.name -    r.file = vim.api.nvim_buf_get_name(buf) -    r.exe = opts.exe or opts.name - -    if opts.filetypes then -        r.filetype = vim.api.nvim_get_option_value("filetype", { scope = "buffer", buf = buf }) -        if not vim.tbl_contains(opts.filetypes, r.filetype) then return nil end -    end - -    if opts.config_files then -        local config_file_list = vim.fs.find(opts.config_files, { path = r.file, upward = true }) -        if #config_file_list == 0 then return nil end -        r.config_file = config_file_list[1] -    end - -    local exe_path, place = M.find_exe(r.file, r.exe, opts.places) -    if exe_path == nil then return nil end -    r.exe_path = exe_path - -    --- @cast place ExePlace -    r.place = place - -    return r -end - -return M diff --git a/configs/nvim/config-root/lua/crupest/utils/nvim.lua b/configs/nvim/config-root/lua/crupest/utils/nvim.lua deleted file mode 100644 index 4477ecc..0000000 --- a/configs/nvim/config-root/lua/crupest/utils/nvim.lua +++ /dev/null @@ -1,12 +0,0 @@ -local M = {} - -function M.close_float() -    local wins = vim.api.nvim_list_wins() -    for _, v in ipairs(wins) do -        if vim.api.nvim_win_get_config(v).relative ~= '' then -            vim.api.nvim_win_close(v, false) -        end -    end -end - -return M diff --git a/configs/nvim/config-root/lua/plugins.lua b/configs/nvim/config-root/lua/plugins.lua deleted file mode 100644 index b689559..0000000 --- a/configs/nvim/config-root/lua/plugins.lua +++ /dev/null @@ -1,30 +0,0 @@ --- spellchecker: disable -return { -    { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, -    "neovim/nvim-lspconfig", -    "L3MON4D3/LuaSnip", -    "hrsh7th/nvim-cmp", -    "hrsh7th/cmp-nvim-lsp", -    "hrsh7th/cmp-buffer", -    "hrsh7th/cmp-path", -    "hrsh7th/cmp-cmdline", -    "saadparwaiz1/cmp_luasnip", -    { -        "nvim-tree/nvim-tree.lua", -        lazy = false, -        dependencies = { -            "nvim-tree/nvim-web-devicons", -        }, -    }, -    { -        "nvim-lualine/lualine.nvim", -        dependencies = { 'nvim-tree/nvim-web-devicons' } -    }, -    { -        "nvim-telescope/telescope.nvim", -        dependencies = { 'nvim-lua/plenary.nvim' } -    }, -    "windwp/nvim-autopairs", -    "mfussenegger/nvim-lint", -    "lewis6991/gitsigns.nvim", -}  | 
