From 11863aa710ab0626eb76648d101854a481664a34 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Mon, 24 Jun 2024 16:45:18 +0800 Subject: Update --- vim/nvim/lua/chadrc.lua | 47 -------- vim/nvim/lua/configs/conform.lua | 15 --- vim/nvim/lua/configs/lazy.lua | 47 -------- vim/nvim/lua/configs/lspconfig.lua | 23 ---- vim/nvim/lua/configs/telescope.lua | 48 -------- vim/nvim/lua/configs/treesitter.lua | 62 ---------- vim/nvim/lua/mappings.lua | 170 ---------------------------- vim/nvim/lua/options.lua | 20 ---- vim/nvim/lua/plugins/init.lua | 218 ------------------------------------ 9 files changed, 650 deletions(-) delete mode 100644 vim/nvim/lua/chadrc.lua delete mode 100644 vim/nvim/lua/configs/conform.lua delete mode 100644 vim/nvim/lua/configs/lazy.lua delete mode 100644 vim/nvim/lua/configs/lspconfig.lua delete mode 100644 vim/nvim/lua/configs/telescope.lua delete mode 100644 vim/nvim/lua/configs/treesitter.lua delete mode 100644 vim/nvim/lua/mappings.lua delete mode 100644 vim/nvim/lua/options.lua delete mode 100644 vim/nvim/lua/plugins/init.lua (limited to 'vim/nvim/lua') diff --git a/vim/nvim/lua/chadrc.lua b/vim/nvim/lua/chadrc.lua deleted file mode 100644 index aa0d78c..0000000 --- a/vim/nvim/lua/chadrc.lua +++ /dev/null @@ -1,47 +0,0 @@ --- This file needs to have same structure as nvconfig.lua --- https://github.com/NvChad/NvChad/blob/v2.5/lua/nvconfig.lua - ----@type ChadrcConfig -local M = {} - -M.ui = { - theme = "onedark", - - -- hl_override = { - -- Comment = { italic = true }, - -- ["@comment"] = { italic = true }, - -- }, - tabufline = { - enabled = true, - }, -} - --- For tabufline -if M.ui.tabufline.enabled then - vim.keymap.set("n", "", function() - local bufnrs = vim.tbl_filter(function(b) - if 1 ~= vim.fn.buflisted(b) then - return false - else - return true - end - end, vim.api.nvim_list_bufs()) - if #bufnrs == 1 then - vim.cmd("silent quit!") - else - require("nvchad.tabufline").close_buffer() - end - end, { desc = "buffer close" }) - for i = 1, 9, 1 do - vim.keymap.set("n", string.format("", i), function() - vim.api.nvim_set_current_buf(vim.t.bufs[i]) - end) - end - vim.keymap.set("n", "", function() require("nvchad.tabufline").move_buf(-1) end) - vim.keymap.set("n", "", function() require("nvchad.tabufline").move_buf(1) end) - vim.keymap.set("n", "", function() vim.cmd("tabprevious") end) - vim.keymap.set("n", "", function() vim.cmd("tabnext") end) -end - - -return M diff --git a/vim/nvim/lua/configs/conform.lua b/vim/nvim/lua/configs/conform.lua deleted file mode 100644 index a000447..0000000 --- a/vim/nvim/lua/configs/conform.lua +++ /dev/null @@ -1,15 +0,0 @@ -local options = { - formatters_by_ft = { - lua = { "stylua" }, - -- css = { "prettier" }, - -- html = { "prettier" }, - }, - - -- format_on_save = { - -- -- These options will be passed to conform.format() - -- timeout_ms = 500, - -- lsp_fallback = true, - -- }, -} - -require("conform").setup(options) diff --git a/vim/nvim/lua/configs/lazy.lua b/vim/nvim/lua/configs/lazy.lua deleted file mode 100644 index cd170bd..0000000 --- a/vim/nvim/lua/configs/lazy.lua +++ /dev/null @@ -1,47 +0,0 @@ -return { - defaults = { lazy = true }, - install = { colorscheme = { "nvchad" } }, - - ui = { - icons = { - ft = "", - lazy = "󰂠 ", - loaded = "", - not_loaded = "", - }, - }, - - performance = { - rtp = { - disabled_plugins = { - "2html_plugin", - "tohtml", - "getscript", - "getscriptPlugin", - "gzip", - "logipat", - "netrw", - "netrwPlugin", - "netrwSettings", - "netrwFileHandlers", - "matchit", - "tar", - "tarPlugin", - "rrhelper", - "spellfile_plugin", - "vimball", - "vimballPlugin", - "zip", - "zipPlugin", - "tutor", - "rplugin", - "syntax", - "synmenu", - "optwin", - "compiler", - "bugreport", - "ftplugin", - }, - }, - }, -} diff --git a/vim/nvim/lua/configs/lspconfig.lua b/vim/nvim/lua/configs/lspconfig.lua deleted file mode 100644 index a73657a..0000000 --- a/vim/nvim/lua/configs/lspconfig.lua +++ /dev/null @@ -1,23 +0,0 @@ --- EXAMPLE -local on_attach = require("nvchad.configs.lspconfig").on_attach -local on_init = require("nvchad.configs.lspconfig").on_init -local capabilities = require("nvchad.configs.lspconfig").capabilities - -local lspconfig = require "lspconfig" -local servers = { "html", "cssls" } - --- lsps with default config -for _, lsp in ipairs(servers) do - lspconfig[lsp].setup { - on_attach = on_attach, - on_init = on_init, - capabilities = capabilities, - } -end - --- typescript -lspconfig.tsserver.setup { - on_attach = on_attach, - on_init = on_init, - capabilities = capabilities, -} diff --git a/vim/nvim/lua/configs/telescope.lua b/vim/nvim/lua/configs/telescope.lua deleted file mode 100644 index 73c64e5..0000000 --- a/vim/nvim/lua/configs/telescope.lua +++ /dev/null @@ -1,48 +0,0 @@ -return { - defaults = { - mappings = { - i = { - -- [""] = "move_selection_next", - -- [""] = "move_selection_previous", - [""] = require("telescope.actions.layout").toggle_preview, - [""] = false, - }, - }, - layout_config = { - horizontal = { - prompt_position = "bottom", - }, - vertical = { height = 0.8 }, - -- other layout configuration here - preview_cutoff = 0, - }, - }, - pickers = { - buffers = { - show_all_buffers = true, - sort_lastused = true, - theme = "dropdown", - previewer = false, - mappings = { - i = { - [""] = "delete_buffer", - }, - n = { - [""] = "delete_buffer", - } - } - }, - - }, - extensions_list = {}, - extensions = { - aerial = { - -- Display symbols as .. - show_nesting = { - ["_"] = false, -- This key will be the default - json = true, -- You can set the option for specific filetypes - yaml = true, - }, - }, - }, -} diff --git a/vim/nvim/lua/configs/treesitter.lua b/vim/nvim/lua/configs/treesitter.lua deleted file mode 100644 index 8375d5b..0000000 --- a/vim/nvim/lua/configs/treesitter.lua +++ /dev/null @@ -1,62 +0,0 @@ -return { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'bash', 'c', 'html', 'css', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = true, - - -- highlight = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']f'] = '@function.outer', - [']c'] = '@class.outer', - }, - goto_next_end = { - [']F'] = '@function.outer', - [']C'] = '@class.outer', - }, - goto_previous_start = { - ['[f'] = '@function.outer', - ['[c'] = '@class.outer', - }, - goto_previous_end = { - ['[F'] = '@function.outer', - ['[C'] = '@class.outer', - }, - }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, - }, - }, -} diff --git a/vim/nvim/lua/mappings.lua b/vim/nvim/lua/mappings.lua deleted file mode 100644 index f6ef8c4..0000000 --- a/vim/nvim/lua/mappings.lua +++ /dev/null @@ -1,170 +0,0 @@ --- require "nvchad.mappings" - --- add yours here - -local map = vim.keymap.set - -map("i", "jk", "") -vim.cmd("command! W execute 'SudaWrite %'") - --- map({ "n", "i", "v" }, "", " w ") - -map("n", "", "noh", { desc = "general clear highlights" }) - --- map("n", "", "%y+", { desc = "file copy whole" }) - --- map("n", "n", "set nu!", { desc = "toggle line number" }) --- map("n", "rn", "set rnu!", { desc = "toggle relative number" }) -map("n", "ch", "NvCheatsheet", { desc = "toggle nvcheatsheet" }) - -map("n", "F", function() - require("conform").format { lsp_fallback = true } -end, { desc = "format files" }) - --- global lsp mappings -map("n", "ds", vim.diagnostic.setloclist, { desc = "lsp diagnostic loclist" }) - --- tabufline -map("n", "", function() - require("nvchad.tabufline").next() -end, { desc = "buffer goto next" }) - -map("n", "", function() - require("nvchad.tabufline").prev() -end, { desc = "buffer goto prev" }) - -map("n", "x", function() - require("nvchad.tabufline").close_buffer() -end, { desc = "buffer close" }) - --- Comment -map("n", "/", "gcc", { desc = "comment toggle", remap = true }) -map("v", "/", "gc", { desc = "comment toggle", remap = true }) - --- nvimtree -map("n", "", "NvimTreeToggle", { desc = "nvimtree toggle window" }) -map("n", "nf", "NvimTreeFocus", { desc = "nvimtree focus window" }) - --- telescope -map("n", "f", "Telescope oldfiles", { desc = "telescope find oldfiles" }) -map("n", "b", "Telescope buffers", { desc = "telescope find buffers" }) -map("n", "/", "Telescope current_buffer_fuzzy_find", { desc = "telescope find in current buffer" }) -map("n", "sf", "Telescope find_files", { desc = "telescope find files" }) -map("n", "sF", "Telescope find_files follow=true no_ignore=true hidden=true", - { desc = "telescope find all files" }) -map("n", "sg", "Telescope live_grep", { desc = "telescope live grep" }) - -map("n", "gf", "Telescope git_files", { desc = "telescope git files" }) -map("n", "sH", "Telescope help_tags", { desc = "telescope help page" }) -map("n", "tt", ":Telescope ", { desc = "telescope help page" }) -map('n', 'sk', "Telescope keymaps", { desc = 'telescope keymaps' }) -map("n", "pt", "Telescope terms", { desc = "telescope pick hidden term" }) - -vim.keymap.set('n', 'ss', function() - local current_filetype = vim.bo.filetype - local cwd = os.getenv("HOME") .. '/snippets/' .. current_filetype - require('telescope.builtin').find_files { - prompt_title = 'Select a snippet for ' .. current_filetype, - cwd = cwd, - attach_mappings = function(prompt_bufnr, map) - local insert_selected_snippet = function() - local file = require('telescope.actions.state').get_selected_entry()[1] - local snippet_content = vim.fn.readfile(cwd .. "/" .. file) - require('telescope.actions').close(prompt_bufnr) - vim.api.nvim_put(snippet_content, '', false, true) - end - - map('i', '', insert_selected_snippet) - map('n', '', insert_selected_snippet) - - return true - end, - } -end, { desc = '[S]earch [S]nippets' }) - -vim.keymap.set('n', 'sn', function() - vim.ui.input({ prompt = 'Snippet Name: ' }, function(snippet_path) - local current_filetype - local snippet - if string.find(snippet_path, "/") then - current_filetype = string.match(snippet_path, "^(.-)/") - snippet = string.match(snippet_path, "/(.-)$") - else - current_filetype = vim.bo.filetype - snippet = snippet_path - end - local dir = os.getenv("HOME") .. '/snippets/' .. current_filetype - local path = dir .. '/' .. snippet - vim.cmd("!mkdir -p" .. dir) - vim.cmd("e " .. path) - vim.cmd("set filetype=" .. current_filetype) - vim.cmd("set filetype?") - end) -end, { desc = "Create a new snippet" }) - - --- map("n", "ma", "Telescope marks", { desc = "telescope find marks" }) --- map("n", "cm", "Telescope git_commits", { desc = "telescope git commits" }) --- map("n", "gt", "Telescope git_status", { desc = "telescope git status" }) --- map("n", "th", "Telescope themes", { desc = "telescope nvchad themes" }) - --- terminal --- map("t", "", "", { desc = "terminal escape terminal mode" }) - --- new terminals -map("n", "h", function() require("nvchad.term").new { pos = "sp" } end, - { desc = "terminal new horizontal term" }) -map("n", "v", function() require("nvchad.term").new { pos = "vsp" } end, - { desc = "terminal new vertical window" }) --- toggleable -map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm" } end, - { desc = "terminal toggleable vertical term" }) -map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" } end, - { desc = "terminal new horizontal term" }) -map({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "float", id = "floatTerm" } end, - { desc = "terminal toggle floating term" }) - --- whichkey -map("n", "wK", "WhichKey ", { desc = "whichkey all keymaps" }) - -map("n", "wk", function() - vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") -end, { desc = "whichkey query lookup" }) - --- blankline -map("n", "cc", function() - local config = { scope = {} } - config.scope.exclude = { language = {}, node_type = {} } - config.scope.include = { node_type = {} } - local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config) - - if node then - local start_row, _, end_row, _ = node:range() - if start_row ~= end_row then - vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 }) - vim.api.nvim_feedkeys("_", "n", true) - end - end -end, { desc = "blankline jump to current context" }) - --- [[ Configure Obsidian.nvim ]] -map('n', "oo", ':Obsidian') -map('n', "ot", ':ObsidianTags') -map('n', "os", ':ObsidianSearch') -map('n', "oq", ':ObsidianQuickSwitch') -map('v', "on", ':ObsidianLinkNew') - --- vim.cmd("let g:mkdp_browser = 'surf'") -vim.cmd("let g:mkdp_browser = 'firefox'") -vim.g.mkdp_preview_options = { - mkit = { breaks = true }, - toc = { - containerClass = "toc", - format = 'function format(x, htmlencode) { return `${htmlencode(x)}`; }', - callback = "console.log('foo')", - } -} - --- [ Configure Hop ] -vim.keymap.set('n', "", ':HopWord') -vim.keymap.set('n', '', ':HopChar1') diff --git a/vim/nvim/lua/options.lua b/vim/nvim/lua/options.lua deleted file mode 100644 index f9e6e7e..0000000 --- a/vim/nvim/lua/options.lua +++ /dev/null @@ -1,20 +0,0 @@ -require "nvchad.options" - --- add yours here! - -local o = vim.o - --- To enable cursorline! -o.cursorlineopt ='both' - --- Let cursor be line in insert mode -o.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" - --- Enable break indent -o.breakindent = true - --- To have a better completion experience -o.completeopt = 'menuone,noselect' - --- NOTE: You should make sure your terminal supports this -o.termguicolors = true diff --git a/vim/nvim/lua/plugins/init.lua b/vim/nvim/lua/plugins/init.lua deleted file mode 100644 index 132f1a2..0000000 --- a/vim/nvim/lua/plugins/init.lua +++ /dev/null @@ -1,218 +0,0 @@ -return { - - -- Detect tabstop and shiftwidth automatically - 'tpope/vim-sleuth', - - -- Use sudo in command mode - { - 'lambdalisue/suda.vim', - cmd = { "SudaWrite" }, - }, - - -- For focus mode - { - "Pocco81/true-zen.nvim", - cmd = { "TZAtaraxis", "TZMinimalist" }, - }, - - -- hop.nvim: For quick jump - { - 'smoka7/hop.nvim', - lazy = false, - version = "*", - opts = { - keys = 'etovxqpdygfblzhckisuran' - }, - config = function() - require("hop").setup() - end - }, - - { - "stevearc/conform.nvim", - -- event = 'BufWritePre', -- uncomment for format on save - config = function() - require "configs.conform" - end, - }, - - { - -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- See `:help ibl` - enabled = false, - main = "ibl", - opts = { - indent = { char = "┊" }, - whitespace = { highlight = { "Whitespace", "NonText" } }, - }, - }, - - { - 'lewis6991/gitsigns.nvim', - opts = { - -- See `:help gitsigns.txt` - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - on_attach = function(bufnr) - vim.keymap.set('n', 'gp', require('gitsigns').prev_hunk, - { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) - vim.keymap.set('n', 'gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) - vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) - vim.keymap.set('n', 'hd', require('gitsigns').diffthis, { buffer = bufnr, desc = '[h]unk [d]iff' }) - vim.keymap.set('n', 'hD', function() require('gitsigns').diffthis('~') end, - { buffer = bufnr, desc = '[h]unk [d]iff for ~' }) - vim.keymap.set('v', 'hr', ":Gitsigns reset_hunk", { buffer = bufnr, desc = '[h]unk [r]eset' }) - end, - }, - }, - - { - "epwalsh/obsidian.nvim", - version = "*", -- recommended, use latest release instead of latest commit - lazy = true, - ft = "markdown", - -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: - -- event = { - -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. - -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" - -- "BufReadPre path/to/my-vault/**.md", - -- "BufNewFile path/to/my-vault/**.md", - -- }, - dependencies = { - -- Required. - "nvim-lua/plenary.nvim", - }, - opts = { - workspaces = { - { - name = "log", - path = "~/log", - }, - }, - completion = { - -- Set to false to disable completion. - nvim_cmp = true, - -- Trigger completion at 2 chars. - min_chars = 2, - }, - mapping = { - -- Toggle check-boxes. - ["oc"] = { - action = function() - return require("obsidian").util.toggle_checkbox() - end, - opts = { buffer = true }, - }, - -- Smart action depending on context, either follow link or toggle checkbox. - [""] = { - action = function() - return require("obsidian").util.smart_action() - end, - opts = { buffer = true, expr = true }, - } - }, - -- see below for full list of options 👇 - note_id_func = function(title) - return title - -- Create note IDs in a Zettelkasten format with a timestamp and a suffix. - -- In this case a note with the title 'My new note' will be given an ID that looks - -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md' - -- local suffix = "" - -- title = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() - -- if title ~= nil and title ~= "" then - -- -- If title is given, transform it into valid file name. - -- suffix = "-" .. title - -- else - -- -- If title is nil, just add 4 random uppercase letters to the suffix. - -- for _ = 1, 4 do - -- suffix = suffix .. string.char(math.random(65, 90)) - -- end - -- suffix = "-" .. title - -- end - -- return tostring(os.time()) .. suffix - end, - }, - }, - - { - "iamcco/markdown-preview.nvim", - cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, - ft = { "markdown" }, - build = function() vim.fn["mkdp#util#install"]() end, - }, - - { - "nvim-telescope/telescope.nvim", - opts = function() - return require "configs.telescope" - end, - }, - - { - "nvim-treesitter/nvim-treesitter", - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - opts = function() - return require "configs.treesitter" - end, - }, - - { - 'stevearc/aerial.nvim', - lazy = false, - event = { "BufReadPost", "BufWritePost", "BufNewFile" }, - opts = { - on_attach = function(bufnr) - -- Jump forwards/backwards with '{' and '}' - vim.keymap.set("n", "{", "AerialPrev", { buffer = bufnr }) - vim.keymap.set("n", "}", "AerialNext", { buffer = bufnr }) - vim.keymap.set("n", "a", "Telescope aerial") - vim.keymap.set("n", "A", "AerialToggle!left") - end, - }, - -- Optional dependencies - dependencies = { - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons" - }, - }, - - -- { - -- 'numToStr/Comment.nvim', - -- lazy = true, - -- opts = { - -- opleader = { - -- ---Line-comment keymap - -- line = '', - -- ---Block-comment keymap - -- block = 'gb', - -- }, - -- } - -- }, - - -- These are some examples, uncomment them if you want to see them work! - -- { - -- "neovim/nvim-lspconfig", - -- config = function() - -- require("nvchad.configs.lspconfig").defaults() - -- require "configs.lspconfig" - -- end, - -- }, - -- - -- { - -- "williamboman/mason.nvim", - -- opts = { - -- ensure_installed = { - -- "lua-language-server", "stylua", - -- "html-lsp", "css-lsp" , "prettier" - -- }, - -- }, - -- }, -} -- cgit v1.2.3-70-g09d2