docs: linting and formatting

remotes/origin/HEAD
Chris Grieser 2023-11-12 14:06:42 +01:00
parent ba59d6fd84
commit cad2c8fb4b
1 changed files with 90 additions and 36 deletions

126
README.md
View File

@ -1,26 +1,24 @@
<!-- LTeX: enabled=false -->
# nvim-genghis ⚔️ # nvim-genghis ⚔️
<a href="https://dotfyle.com/plugins/chrisgrieser/nvim-genghis"><img src="https://dotfyle.com/plugins/chrisgrieser/nvim-genghis/shield" /></a> <!-- LTeX: enabled=true -->
<a href="https://dotfyle.com/plugins/chrisgrieser/nvim-genghis">
<img src="https://dotfyle.com/plugins/chrisgrieser/nvim-genghis/shield"/></a>
Convenience file operations for neovim, written in lua. Lightweight plugin providing file operations without a full-blown file tree.
<!-- toc -->
<!--toc:start-->
- [How is this different from `vim.eunuch`?](#how-is-this-different-from-vimeunuch)
- [Installation and Setup](#installation-and-setup) - [Installation and Setup](#installation-and-setup)
- [Available Commands](#available-commands) - [Available Commands](#available-commands)
- [File Operation Command](#file-operation-command) * [File Operation Command](#file-operation-command)
- [File Utility Commands](#file-utility-commands) * [File Utility Commands](#file-utility-commands)
- [Disable Ex-Commands](#disable-ex-commands) * [Disable Ex-Commands](#disable-ex-commands)
- [Autocompletion of directories](#autocompletion-of-directories) - [Autocompletion of directories](#autocompletion-of-directories)
- [How is this different from `vim.eunuch`?](#how-is-this-different-from-vimeunuch)
- [Why that name](#why-that-name) - [Why that name](#why-that-name)
- [About me](#about-me) - [About me](#about-me)
<!--toc:end-->
## How is this different from `vim.eunuch`? <!-- tocstop -->
- Various improvements like automatically keeping the extensions when no extension is given, or moving files to the trash instead of removing them.
- Uses only vim-commands or lua os-modules, so it has no dependencies and works cross-platform.
- Makes use of up-to-date nvim features like `vim.ui.input` or `vim.notify`. This means you can get nicer input fields with normal mode support via plugins like [dressing.nvim](https://github.com/stevearc/dressing.nvim), and confirmation notices with plugins like [nvim-notify](https://github.com/rcarriga/nvim-notify), if they are installed and setup.
- If used with dressing and cmp, [you can also get autocompletion of directories](#autocompletion-of-directories).
- Written 100% in lua.
## Installation and Setup ## Installation and Setup
@ -32,7 +30,8 @@ use {"chrisgrieser/nvim-genghis", requires = "stevearc/dressing.nvim"}
{"chrisgrieser/nvim-genghis", dependencies = "stevearc/dressing.nvim"}, {"chrisgrieser/nvim-genghis", dependencies = "stevearc/dressing.nvim"},
``` ```
`nvim-genghis` (and `dressing.nvim`) require no `.setup()` function. Just create keybindings for the commands you want to use: `nvim-genghis` (and `dressing.nvim`) require no `.setup()` function. Just create
keybindings for the commands you want to use:
```lua ```lua
local keymap = vim.keymap.set local keymap = vim.keymap.set
@ -44,7 +43,7 @@ keymap("n", "<leader>rf", genghis.renameFile)
keymap("n", "<leader>mf", genghis.moveAndRenameFile) keymap("n", "<leader>mf", genghis.moveAndRenameFile)
keymap("n", "<leader>nf", genghis.createNewFile) keymap("n", "<leader>nf", genghis.createNewFile)
keymap("n", "<leader>yf", genghis.duplicateFile) keymap("n", "<leader>yf", genghis.duplicateFile)
keymap("n", "<leader>df", function () genghis.trashFile{trashLocation = "your/path"} end) -- default: "$HOME/.Trash". keymap("n", "<leader>df", function() genghis.trashFile { trashLocation = "your/path" } end) -- default: "$HOME/.Trash".
keymap("x", "<leader>x", genghis.moveSelectionToNewFile) keymap("x", "<leader>x", genghis.moveSelectionToNewFile)
``` ```
@ -53,27 +52,57 @@ keymap("x", "<leader>x", genghis.moveSelectionToNewFile)
### File Operation Command ### File Operation Command
- `.createNewFile` or `:New`: Create a new file. - `.createNewFile` or `:New`: Create a new file.
- `.duplicateFile` or `:Duplicate`: Duplicate the current file. - `.duplicateFile` or `:Duplicate`: Duplicate the current file.
- `.moveSelectionToNewFile` or `:NewFromSelection`: Prompts for a new file name and moves the current selection to that new file. (Note that this is a Visual Line Mode command; the selection is moved linewise.) - `.moveSelectionToNewFile` or `:NewFromSelection`: Prompts for a new file name
and moves the current selection to that new file. (Note that this is a Visual
Line Mode command; the selection is moved linewise.)
- `.renameFile` or `:Rename`: Rename the current file. - `.renameFile` or `:Rename`: Rename the current file.
- `.moveAndRenameFile` or `:Move`: Move and Rename the current file. Works like the UNIX `mv` command. Best used with [autocompletion of directories](#autocompletion-of-directories). - `.moveAndRenameFile` or `:Move`: Move and Rename the current file. Works like
the UNIX `mv` command. Best used with [autocompletion of
directories](#autocompletion-of-directories).
The following applies to all commands above: The following applies to all commands above:
- If no extension has been provided, uses the extension of the original file. - If no extension has been provided, uses the extension of the original file.
- If the new file name includes a `/`, the new file is placed in the respective subdirectory, creating any non-existing folders. Except for `.moveAndRenameFile`, all operations take only place in the current working directory, so `.moveAndRenameFile` is the only command that can move to a parent directory. - If the new file name includes a `/`, the new file is placed in the respective
subdirectory, creating any non-existing folders. Except for
`.moveAndRenameFile`, all operations take only place in the current working
directory, so `.moveAndRenameFile` is the only command that can move to a parent
directory.
- All commands support [autocompletion of existing directories](#autocompletion-of-directories). - All commands support [autocompletion of existing directories](#autocompletion-of-directories).
`renameFile` and `moveAndRenameFile` will notify any running LSP client about the renaming. LSP servers supporting the `workspace/willRenameFiles` method can use this information to update various code parts, for example `use` or `import` statements. `renameFile` and `moveAndRenameFile` notify any running LSP client about
the renaming. LSP servers supporting the `workspace/willRenameFiles` method can
use this information to update various code parts, for example `use` or `import`
statements.
### File Utility Commands ### File Utility Commands
- `.trashFile{trashLocation = "/your/path/"}` or `:Trash`: Move the current file to the trash location. [Defaults to the operating-system-specific trash directory.](https://github.com/chrisgrieser/nvim-genghis/blob/main/lua/genghis.lua#L164) ⚠️ Any existing file in the trash location with the same name is overwritten, making that file irretrievable. If [bufdelete.nvim](https://github.com/famiu/bufdelete.nvim) is available, `require'bufdelete.nvim'.bufwipeout` would be used to keep window layout intact instead of `vim.cmd.bwipeout`. - `.trashFile{trashLocation = "/your/path/"}` or `:Trash`: Move the current file
- `.copyFilename` or `:CopyFilename`: Copy the file name. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise to `"`. to the trash location. [Defaults to the operating-system-specific trash
- `.copyFilepath` or `:CopyFilepath`: Copy the absolute file path. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise to `"`. directory.](https://github.com/chrisgrieser/nvim-genghis/blob/main/lua/genghis.lua#L164)
- `.copyRelativePath` or `:CopyRelativePath`: Copy the relative file path. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise to `"`. ⚠️ Any existing file in the trash location with the same name is overwritten,
- `.copyDirectoryPath` or `:CopyDirectoryPath`: Copy the absolute directory path. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise to `"`. making that file irretrievable. If
- `.copyRelativeDirectoryPath` or `:CopyRelativeDirectoryPath`: Copy the relative directory path. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise to `"`. [bufdelete.nvim](https://github.com/famiu/bufdelete.nvim) is available,
- `.chmodx` or `:Chmodx`: Makes current file executable. Equivalent to `chmod +x`. `require'bufdelete.nvim'.bufwipeout` would be used to keep window layout intact
instead of `vim.cmd.bwipeout`.
- `.copyFilename` or `:CopyFilename`: Copy the file name. When
`clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise
to `"`.
- `.copyFilepath` or `:CopyFilepath`: Copy the absolute file path. When
`clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise
to `"`.
- `.copyRelativePath` or `:CopyRelativePath`: Copy the relative file path. When
`clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise
to `"`.
- `.copyDirectoryPath` or `:CopyDirectoryPath`: Copy the absolute directory
path. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register,
otherwise to `"`.
- `.copyRelativeDirectoryPath` or `:CopyRelativeDirectoryPath`: Copy the
relative directory path. When `clipboard="unnamed[plus]"` has been set, copies
to the `+` register, otherwise to `"`.
- `.chmodx` or `:Chmodx`: Makes current file executable. Equivalent to `chmod
+x`.
To always use system clipboard put this in your configuration file: To always use system clipboard put this in your configuration file:
```lua ```lua
-- lua -- lua
vim.g.genghis_use_systemclipboard = true vim.g.genghis_use_systemclipboard = true
@ -98,7 +127,8 @@ let g:genghis_disable_commands = v:true
``` ```
## Autocompletion of directories ## Autocompletion of directories
You can get autocompletion for directories by using `dressing.nvim`, `nvim-cmp`, and vim's omnifunc: You can get autocompletion for directories by using `dressing.nvim`, `nvim-cmp`,
and vim's `omnifunc`:
```lua ```lua
-- packer -- packer
@ -120,19 +150,38 @@ use { "chrisgrieser/nvim-genghis", requires = {
```lua ```lua
-- required setup for cmp, somewhere after your main cmp-config -- required setup for cmp, somewhere after your main cmp-config
require("cmp").setup.filetype("DressingInput", { require("cmp").setup.filetype("DressingInput", {
sources = cmp.config.sources { {name = "omni"} }, sources = cmp.config.sources { { name = "omni" } },
}) })
``` ```
## How is this different from `vim.eunuch`?
- Various improvements like automatically keeping the extensions when no
extension is given, or moving files to the trash instead of removing them.
- Uses only vim-commands or lua `os` modules, so it has no dependencies and
works cross-platform.
- Makes use of up-to-date nvim features like `vim.ui.input` or `vim.notify`.
This means you can get nicer input fields with normal mode support via plugins
like [dressing.nvim](https://github.com/stevearc/dressing.nvim), and
confirmation notices with plugins like
[nvim-notify](https://github.com/rcarriga/nvim-notify), if they are installed
and setup.
- LSP support when renaming.
- Written 100% in lua.
## Why that name ## Why that name
A nod to [vim.eunuch](https://github.com/tpope/vim-eunuch) - as opposed to childless eunuchs, it is said that Genghis Khan [has fathered thousands of children](https://allthatsinteresting.com/genghis-khan-children). A nod to [vim.eunuch](https://github.com/tpope/vim-eunuch). As opposed to
childless eunuchs, it is said that Genghis Khan [has fathered thousands of
children](https://allthatsinteresting.com/genghis-khan-children).
<!-- vale Google.FirstPerson = NO --> <!-- vale Google.FirstPerson = NO -->
## About me ## About me
In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch. In my day job, I am a sociologist studying the social mechanisms underlying the
digital economy. For my PhD project, I investigate the governance of the app
economy and how software ecosystems manage the tension between innovation and
compatibility. If you are interested in this subject, feel free to get in touch.
__Blog__ __Blog__
I also occassionally blog about vim: [Nano Tips for Vim](https://nanotipsforvim.prose.sh) I also occasionally blog about vim: [Nano Tips for Vim](https://nanotipsforvim.prose.sh)
__Profiles__ __Profiles__
- [Discord](https://discordapp.com/users/462774483044794368/) - [Discord](https://discordapp.com/users/462774483044794368/)
@ -142,6 +191,11 @@ __Profiles__
- [ResearchGate](https://www.researchgate.net/profile/Christopher-Grieser) - [ResearchGate](https://www.researchgate.net/profile/Christopher-Grieser)
- [LinkedIn](https://www.linkedin.com/in/christopher-grieser-ba693b17a/) - [LinkedIn](https://www.linkedin.com/in/christopher-grieser-ba693b17a/)
__Buy Me a Coffee__   <a href='https://ko-fi.com/Y8Y86SQ91' target='_blank'>
<br> <img
<a href='https://ko-fi.com/Y8Y86SQ91' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi1.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a> height='36'
style='border:0px;height:36px;'
src='https://cdn.ko-fi.com/cdn/kofi1.png?v=3'
border='0'
alt='Buy Me a Coffee at ko-fi.com'
/></a>