diff --git a/cheats.md b/cheats.md new file mode 100644 index 0000000..0a4ff63 --- /dev/null +++ b/cheats.md @@ -0,0 +1,41 @@ +# Cheats + +## Motions +- `cgn` change word under cursor, then `.` to repeat on next match +- `gc` comment motion (e.g. `gc3j`, `gcap`) +- `gcc` toggle comment on current line + +## fzf +- `f` find files +- `g` live grep +- `b` buffers +- `o` old files +- `s` grep word under cursor across project + +## Terminal +- `` toggle terminal +- `` exit terminal mode (back to normal mode) + +## Oil +- `-` open oil (current file's directory) +- `-` go to cwd root +- `-` go up a directory (inside oil) +- `` open file/directory +- `g.` toggle hidden files + +## Clipboard +- `y` yank to system clipboard (normal/visual) +- `p` paste from system clipboard + +## General +- `h` clear search highlight +- `:Cheats` open this file + +## System Dependencies +- `fzf` fuzzy finder binary (required by fzf-lua) +- `rg` ripgrep — required for live grep and grep word (`g`, `s`) +- `fd` faster file finding (optional, fzf-lua uses it automatically if present) +- `wl-clipboard` / `xclip` system clipboard on Linux (Wayland / X11) + +Arch: `sudo pacman -S fzf ripgrep fd wl-clipboard` +macOS: `brew install fzf ripgrep fd` \ No newline at end of file diff --git a/lua/fzf-config.lua b/lua/fzf-config.lua new file mode 100644 index 0000000..d11a404 --- /dev/null +++ b/lua/fzf-config.lua @@ -0,0 +1,7 @@ +local fzf = require("fzf-lua") + +vim.keymap.set("n", "f", fzf.files) +vim.keymap.set("n", "g", fzf.live_grep) +vim.keymap.set("n", "b", fzf.buffers) +vim.keymap.set("n", "o", fzf.oldfiles) +vim.keymap.set("n", "s", fzf.grep_cword) diff --git a/lua/man-config.lua b/lua/man-config.lua new file mode 100644 index 0000000..8deebf0 --- /dev/null +++ b/lua/man-config.lua @@ -0,0 +1,24 @@ +vim.schedule(function() +vim.api.nvim_del_user_command('Man') +vim.api.nvim_create_user_command('Man', function(params) + local man = require('man') + if params.bang then + man.init_pager() + else + params.smods.tab = 1 + local _, err = pcall(man.open_page, params.count, params.smods, params.fargs) + if err then + vim.notify('man.lua: ' .. err, vim.log.levels.ERROR) + end + end +end, { + bang = true, + bar = true, + range = true, + addr = 'other', + nargs = '*', + complete = function(...) + return require('man').man_complete(...) + end, +}) +end) diff --git a/lua/oil-config.lua b/lua/oil-config.lua new file mode 100644 index 0000000..01c47c4 --- /dev/null +++ b/lua/oil-config.lua @@ -0,0 +1,20 @@ +require("oil").setup({ + default_file_explorer = true, + delete_to_trash = true, + watch_for_changes = true, + skip_confirm_for_simple_edits = true, + columns = { "icon", "size" }, + view_options = { + show_hidden = true, + }, + keymaps = { + ["-"] = function() + require("oil").open(vim.fn.getcwd()) + end, + [""] = function() + require("toggleterm").toggle(1, 15, require("oil").get_current_dir(), "horizontal") + end, + }, +}) + +vim.keymap.set("n", "-", "Oil") diff --git a/lua/telescope-config.lua b/lua/telescope-config.lua new file mode 100644 index 0000000..7ac7067 --- /dev/null +++ b/lua/telescope-config.lua @@ -0,0 +1,7 @@ +local builtin = require("telescope.builtin") + +vim.keymap.set("n", "f", builtin.find_files) +vim.keymap.set("n", "g", builtin.live_grep) +vim.keymap.set("n", "b", builtin.buffers) +vim.keymap.set("n", "o", builtin.oldfiles) +vim.keymap.set("n", "s", builtin.grep_string) diff --git a/lua/treesitter.lua b/lua/treesitter.lua new file mode 100644 index 0000000..ed45578 --- /dev/null +++ b/lua/treesitter.lua @@ -0,0 +1,28 @@ +local jai_entry = { + install_info = { + url = "https://github.com/constantitus/tree-sitter-jai", + files = { "src/parser.c" }, + branch = "main", + }, + tier = 3, +} + +-- parsers.lua is a plain table with no side effects, so loadfile is safe here. +-- We need preload rather than a one-time mutation because install.lua calls +-- reload_parsers() (package.loaded = nil + re-require) before checking languages. +local parsers_path = vim.fn.globpath(vim.o.rtp, "lua/nvim-treesitter/parsers.lua", 0, 1)[1] +package.preload["nvim-treesitter.parsers"] = function() + local parsers = assert(loadfile(parsers_path))() + parsers.jai = jai_entry + return parsers +end + +vim.filetype.add({ extension = { jai = "jai" } }) + +vim.api.nvim_create_autocmd("FileType", { + pattern = "jai", + callback = function() + vim.treesitter.start() + vim.bo.commentstring = "// %s" + end, +})