diff options
20 files changed, 122 insertions, 322 deletions
diff --git a/store/home/config/nvim/init.lua b/store/home/config/nvim/init.lua index d9349e1..881ce15 100644 --- a/store/home/config/nvim/init.lua +++ b/store/home/config/nvim/init.lua @@ -7,35 +7,6 @@ if vim.g.neovide then vim.g.neovide_input_macos_option_key_is_meta = 'only_left' end -local is_win = vim.fn.has("win32") ~= 0 - --- spellchecker: disable -if is_win then - vim.cmd([[ - let &shell = executable('pwsh') ? 'pwsh' : 'powershell' - let &shellcmdflag = '-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';Remove-Alias -Force -ErrorAction SilentlyContinue tee;' - let &shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode' - let &shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode' - set shellquote= shellxquote= - ]]) - vim.opt.completeslash = 'slash' -end --- spellchecker: enable - --- spellchecker: disable -vim.opt.termguicolors = true; -vim.opt.fileformats = "unix,dos"; -vim.opt.softtabstop = 4; -vim.opt.shiftwidth = 4; -vim.opt.expandtab = true; -vim.opt.wrap = false; -vim.opt.number = true; --- spellchecker: enable - -vim.g.load_doxygen_syntax = true; -vim.g.doxygen_javadoc_autobrief = false; - --- Init lazy.nvim local lazy_path = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.uv.fs_stat(lazy_path) then vim.fn.system({ @@ -48,14 +19,9 @@ if not vim.uv.fs_stat(lazy_path) then }) end vim.opt.rtp:prepend(lazy_path) - --- Use lazy.nvim require("lazy").setup("plugins") vim.cmd("colorscheme catppuccin-macchiato") -require("crupest.nvim.lsp").setup() -require("crupest.nvim.plugins").setup() -require("crupest.nvim.keymap").setup() +require("setup").setup() -vim.cmd("autocmd FileType gitcommit,gitrebase,gitconfig set bufhidden=delete") diff --git a/store/home/config/nvim/lazy-lock.json b/store/home/config/nvim/lazy-lock.json index 76f55b8..985a07d 100644 --- a/store/home/config/nvim/lazy-lock.json +++ b/store/home/config/nvim/lazy-lock.json @@ -1,18 +1,15 @@ { - "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, "catppuccin": { "branch": "main", "commit": "5b5e3aef9ad7af84f463d17b5479f06b87d5c429" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "gitsigns.nvim": { "branch": "main", "commit": "4c40357994f386e72be92a46f41fc1664c84c87d" }, + "gitsigns.nvim": { "branch": "main", "commit": "011dc6718bcebdf92a5336bb0da79189c3afe621" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" }, "nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" }, "nvim-cmp": { "branch": "main", "commit": "c27370703e798666486e3064b64d59eaf4bdc6d5" }, "nvim-lint": { "branch": "master", "commit": "6e9dd545a1af204c4022a8fcd99727ea41ffdcc8" }, - "nvim-lspconfig": { "branch": "master", "commit": "84e0cd5a3c58e88ef706fdf4a1eed59ded1d3ce2" }, + "nvim-lspconfig": { "branch": "master", "commit": "8a1529e46eef5efc86c34c8d9bdd313abc2ecba0" }, "nvim-tree.lua": { "branch": "master", "commit": "c09ff35de503a41fa62465c6b4ae72d96e7a7ce4" }, "nvim-web-devicons": { "branch": "master", "commit": "ab4cfee554e501f497bce0856788d43cf2eb93d7" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, diff --git a/store/home/config/nvim/lua/crupest/nvim/keymap.lua b/store/home/config/nvim/lua/crupest/nvim/keymap.lua deleted file mode 100644 index 624c04c..0000000 --- a/store/home/config/nvim/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/store/home/config/nvim/lua/crupest/nvim/plugins/gitsigns.lua b/store/home/config/nvim/lua/crupest/nvim/plugins/gitsigns.lua deleted file mode 100644 index 220c91a..0000000 --- a/store/home/config/nvim/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/store/home/config/nvim/lua/crupest/nvim/plugins/init.lua b/store/home/config/nvim/lua/crupest/nvim/plugins/init.lua deleted file mode 100644 index 24e0c2e..0000000 --- a/store/home/config/nvim/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/store/home/config/nvim/lua/crupest/nvim/plugins/others.lua b/store/home/config/nvim/lua/crupest/nvim/plugins/others.lua deleted file mode 100644 index 2ef0d75..0000000 --- a/store/home/config/nvim/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/store/home/config/nvim/lua/crupest/nvim/plugins/snip.lua b/store/home/config/nvim/lua/crupest/nvim/plugins/snip.lua deleted file mode 100644 index 78ed2eb..0000000 --- a/store/home/config/nvim/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/store/home/config/nvim/lua/crupest/utils/find.lua b/store/home/config/nvim/lua/crupest/utils/find.lua deleted file mode 100644 index dd1f663..0000000 --- a/store/home/config/nvim/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/store/home/config/nvim/lua/crupest/utils/nvim.lua b/store/home/config/nvim/lua/crupest/utils/nvim.lua deleted file mode 100644 index 4477ecc..0000000 --- a/store/home/config/nvim/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/store/home/config/nvim/lua/plugins.lua b/store/home/config/nvim/lua/plugins.lua index b689559..abbb13b 100644 --- a/store/home/config/nvim/lua/plugins.lua +++ b/store/home/config/nvim/lua/plugins.lua @@ -2,13 +2,10 @@ 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, diff --git a/store/home/config/nvim/lua/setup/init.lua b/store/home/config/nvim/lua/setup/init.lua new file mode 100644 index 0000000..91bd718 --- /dev/null +++ b/store/home/config/nvim/lua/setup/init.lua @@ -0,0 +1,45 @@ +local function 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 + +local function setup() + if vim.fn.has("win32") ~= 0 then + require("setup.win").setup() + end + + -- spellchecker: ignore termguicolors + vim.opt.termguicolors = true; + vim.opt.fileformats = "unix,dos"; + vim.opt.number = true; + + vim.g.load_doxygen_syntax = true; + vim.g.doxygen_javadoc_autobrief = false; + + vim.keymap.set("n", "<c-tab>", "<cmd>bnext<cr>") + vim.keymap.set("n", "<c-s-tab>", "<cmd>bNext<cr>") + vim.keymap.set("n", "<esc>", close_float) + vim.keymap.set('t', '<A-n>', '<C-\\><C-n>') + vim.keymap.set('t', '<A-p>', function() + local register = vim.fn.input("Enter register: ") + if register == "" then + register = '"' + end + return '<C-\\><C-N>"' .. register .. 'pi' + end, { expr = true }) + + vim.cmd("autocmd FileType gitcommit,gitrebase,gitconfig set bufhidden=delete") + + vim.diagnostic.config({ virtual_text = true }) + + require("setup.lsp").setup() + require("setup.plugins").setup() +end + +return { + setup = setup +} diff --git a/store/home/config/nvim/lua/crupest/nvim/lsp/c.lua b/store/home/config/nvim/lua/setup/lsp/clangd.lua index 6080510..6080510 100644 --- a/store/home/config/nvim/lua/crupest/nvim/lsp/c.lua +++ b/store/home/config/nvim/lua/setup/lsp/clangd.lua diff --git a/store/home/config/nvim/lua/crupest/nvim/lsp/init.lua b/store/home/config/nvim/lua/setup/lsp/init.lua index ba11087..e87c2be 100644 --- a/store/home/config/nvim/lua/crupest/nvim/lsp/init.lua +++ b/store/home/config/nvim/lua/setup/lsp/init.lua @@ -15,8 +15,8 @@ lspconfig.util.default_config = vim.tbl_extend( local function setup() lspconfig.cmake.setup {} lspconfig.bashls.setup {} - require("crupest.nvim.lsp.c").setup() - require("crupest.nvim.lsp.lua").setup() + require("setup.lsp.clangd").setup() + require("setup.lsp.lua_ls").setup() end diff --git a/store/home/config/nvim/lua/crupest/nvim/lsp/lua.lua b/store/home/config/nvim/lua/setup/lsp/lua_ls.lua index 93aa503..93aa503 100644 --- a/store/home/config/nvim/lua/crupest/nvim/lsp/lua.lua +++ b/store/home/config/nvim/lua/setup/lsp/lua_ls.lua diff --git a/store/home/config/nvim/lua/crupest/nvim/plugins/cmp.lua b/store/home/config/nvim/lua/setup/plugins/cmp.lua index 2244443..c977943 100644 --- a/store/home/config/nvim/lua/crupest/nvim/plugins/cmp.lua +++ b/store/home/config/nvim/lua/setup/plugins/cmp.lua @@ -1,11 +1,10 @@ local function setup() local cmp = require("cmp") - local luasnip = require("luasnip") cmp.setup { snippet = { expand = function(args) - luasnip.lsp_expand(args.body) + vim.snippet.expand(args.body) end, }, window = { @@ -22,7 +21,7 @@ local function setup() }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, - { name = 'luasnip' }, + { name = 'path' }, }, { { name = 'buffer' }, }) diff --git a/store/home/config/nvim/lua/setup/plugins/gitsigns.lua b/store/home/config/nvim/lua/setup/plugins/gitsigns.lua new file mode 100644 index 0000000..957c661 --- /dev/null +++ b/store/home/config/nvim/lua/setup/plugins/gitsigns.lua @@ -0,0 +1,40 @@ +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>gc', gitsigns.preview_hunk) + map('n', '<leader>gt', gitsigns.toggle_deleted) + map('n', '<leader>gd', gitsigns.diffthis) + map('n', '<leader>gb', function() gitsigns.blame_line { full = true } end) + end + } +end + +return { + setup = setup +} diff --git a/store/home/config/nvim/lua/setup/plugins/init.lua b/store/home/config/nvim/lua/setup/plugins/init.lua new file mode 100644 index 0000000..0e2a839 --- /dev/null +++ b/store/home/config/nvim/lua/setup/plugins/init.lua @@ -0,0 +1,14 @@ +local function setup() + require("setup.plugins.lint").setup() + require("setup.plugins.cmp").setup() + require("setup.plugins.telescope").setup() + require("setup.plugins.gitsigns").setup() + + require('lualine').setup {} + require("nvim-tree").setup {} + require("nvim-autopairs").setup {} +end + +return { + setup = setup +} diff --git a/store/home/config/nvim/lua/crupest/nvim/plugins/lint.lua b/store/home/config/nvim/lua/setup/plugins/lint.lua index e2dff1b..688e5ca 100644 --- a/store/home/config/nvim/lua/crupest/nvim/plugins/lint.lua +++ b/store/home/config/nvim/lua/setup/plugins/lint.lua @@ -16,7 +16,6 @@ local cspell = { "cspell.yml", }, fast = true, - initialized = false } local linters = { cspell } @@ -32,10 +31,6 @@ local function cru_lint(linter, opt) if 0 ~= #vim.fs.find(linter.config_patterns, { path = vim.api.nvim_buf_get_name(opt.buf), upward = true }) then - if not linter.initialized then - vim.diagnostic.config({ virtual_text = true }, lint.get_namespace(linter.name)) - linter.initialized = true - end lint.try_lint(linter.name) end end diff --git a/store/home/config/nvim/lua/crupest/nvim/plugins/telescope.lua b/store/home/config/nvim/lua/setup/plugins/telescope.lua index d68b7f2..d68b7f2 100644 --- a/store/home/config/nvim/lua/crupest/nvim/plugins/telescope.lua +++ b/store/home/config/nvim/lua/setup/plugins/telescope.lua diff --git a/store/home/config/nvim/lua/setup/win.lua b/store/home/config/nvim/lua/setup/win.lua new file mode 100644 index 0000000..90e168a --- /dev/null +++ b/store/home/config/nvim/lua/setup/win.lua @@ -0,0 +1,16 @@ +-- spellchecker: words pwsh +-- spellchecker: ignore shellcmdflag shellredir shellpipe shellquote shellxquote +local function setup() + vim.cmd([[ + let &shell = executable('pwsh') ? 'pwsh' : 'powershell' + let &shellcmdflag = '-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';Remove-Alias -Force -ErrorAction SilentlyContinue tee;' + let &shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode' + let &shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode' + set shellquote= shellxquote= + ]]) + vim.opt.completeslash = 'slash' +end + +return { + setup = setup +} |