Merge branch 'main' into commands
commit
ed2a8a6dc9
39
README.md
39
README.md
|
|
@ -20,11 +20,11 @@ Convenience file operations for neovim, written in lua.
|
|||
## Installation and Setup
|
||||
|
||||
```lua
|
||||
-- Recommended (Packer)
|
||||
-- Packer
|
||||
use {"chrisgrieser/nvim-genghis", requires = "stevearc/dressing.nvim"}
|
||||
|
||||
-- if you do not care about nice input fields
|
||||
use "chrisgrieser/nvim-genghis"
|
||||
-- Lazy
|
||||
{"chrisgrieser/nvim-genghis", dependencies = "stevearc/dressing.nvim"},
|
||||
```
|
||||
|
||||
`nvim-genghis` (and `dressign.nvim`) require no `.setup()` function. Just create keybindings for the commands you want to use:
|
||||
|
|
@ -47,8 +47,8 @@ keymap("x", "<leader>x", genghis.moveSelectionToNewFile)
|
|||
- `.createNewFile` or `:New`: Create a new 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.)
|
||||
- `.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).
|
||||
- `.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).
|
||||
|
||||
> __Note__
|
||||
> Applying to all commands above:
|
||||
|
|
@ -56,22 +56,29 @@ keymap("x", "<leader>x", genghis.moveSelectionToNewFile)
|
|||
> - 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).
|
||||
|
||||
- `.trashFile{trashLocation = "your/path/"}` or `Trash`: Move the current file the trash location. Defaults to location is `$HOME/.Trash/`. ⚠️ Any existing file in the trash location with the same name is overwritten, making that file irretrievable.
|
||||
- `.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 `"`.
|
||||
- `.chmodx` or `Chmodx`: Makes current file executable. Equivalent to `chmod +x`.
|
||||
- `.trashFile{trashLocation = "your/path/"}` or `:Trash`: Move the current file the trash location. Defaults to location is `$HOME/.Trash/`. ⚠️ Any existing file in the trash location with the same name is overwritten, making that file irretrievable.
|
||||
- `.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 `"`.
|
||||
- `.chmodx` or `:Chmodx`: Makes current file executable. Equivalent to `chmod +x`.
|
||||
|
||||
## Autocompletion of directories
|
||||
You can get autocompletion for directories by using `dressing.nvim`, `nvim-cmp`, and vim's omnifunc:
|
||||
|
||||
```lua
|
||||
-- packer
|
||||
use { "chrisgrieser/nvim-genghis", requires = {
|
||||
"stevearc/dressing.nvim",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-omni",
|
||||
},
|
||||
}
|
||||
-- packer
|
||||
use { "chrisgrieser/nvim-genghis", requires = {
|
||||
"stevearc/dressing.nvim",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-omni",
|
||||
},
|
||||
}
|
||||
-- lazy
|
||||
{ "chrisgrieser/nvim-genghis", dependencies = {
|
||||
"stevearc/dressing.nvim",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-omni",
|
||||
},
|
||||
},
|
||||
```
|
||||
|
||||
```lua
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
*genghis.txt* For NVIM v0.8.0 Last change: 2023 January 08
|
||||
*genghis.txt* For NVIM v0.8.0 Last change: 2023 February 05
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *genghis-table-of-contents*
|
||||
|
|
@ -39,11 +39,11 @@ HOW IS THIS DIFFERENT FROM `VIM.EUNUCH`?*genghis-how-is-this-different-from-`vim
|
|||
INSTALLATION AND SETUP *genghis-installation-and-setup*
|
||||
|
||||
>
|
||||
-- Recommended (Packer)
|
||||
-- Packer
|
||||
use {"chrisgrieser/nvim-genghis", requires = "stevearc/dressing.nvim"}
|
||||
|
||||
-- if you do not care about nice input fields
|
||||
use "chrisgrieser/nvim-genghis"
|
||||
-- Lazy
|
||||
{"chrisgrieser/nvim-genghis", dependencies = "stevearc/dressing.nvim"},
|
||||
<
|
||||
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ AVAILABLE COMMANDS *genghis-available-commands*
|
|||
|
||||
|
||||
|
||||
- `.trashFile{trashLocation = "your/path/"}`: Move the current file the trash location. Defaults to location is `$HOME/.Trash/`. ⚠️ Any existing file in the trash location with the same name is overwritten, making that file irretrievable.
|
||||
- `.trashFile{trashLocation = "your/path/"}`: Move the current file the trash location. Default locations are: `$HOME/.Trash/` on MacOS and `$XDG_DATA_HOME/Trash` on Linux. ⚠️ Any existing file in the trash location with the same name is overwritten, making that file irretrievable.
|
||||
- `.copyFilename`: Copy the file name. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise to `"`.
|
||||
- `.copyFilepath`: Copy the absolute file path. When `clipboard="unnamed[plus]"` has been set, copies to the `+` register, otherwise to `"`.
|
||||
- `.chmodx`: Makes current file executable. Equivalent to `chmod +x`.
|
||||
|
|
@ -98,13 +98,20 @@ You can get autocompletion for directories by using `dressing.nvim`,
|
|||
`nvim-cmp`, and vim’s omnifunc:
|
||||
|
||||
>
|
||||
-- packer
|
||||
use { "chrisgrieser/nvim-genghis", requires = {
|
||||
"stevearc/dressing.nvim",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-omni",
|
||||
},
|
||||
}
|
||||
-- packer
|
||||
use { "chrisgrieser/nvim-genghis", requires = {
|
||||
"stevearc/dressing.nvim",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-omni",
|
||||
},
|
||||
}
|
||||
-- lazy
|
||||
{ "chrisgrieser/nvim-genghis", dependencies = {
|
||||
"stevearc/dressing.nvim",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"hrsh7th/cmp-omni",
|
||||
},
|
||||
},
|
||||
<
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,19 @@ end
|
|||
---@param opts? table
|
||||
function M.trashFile(opts)
|
||||
cmd.update { bang = true }
|
||||
local trash = os.getenv("HOME") .. "/.Trash/"
|
||||
local trash
|
||||
|
||||
if vim.fn.has('linux') == 1 then
|
||||
local xdg_data = os.getenv("XDG_DATA_HOME")
|
||||
if xdg_data then
|
||||
trash = xdg_data .. "/Trash"
|
||||
else
|
||||
trash = os.getenv("HOME") .. "/.local/share/Trash"
|
||||
end
|
||||
else
|
||||
trash = os.getenv("HOME") .. "/.Trash"
|
||||
end
|
||||
|
||||
if opts and opts.trashLocation then
|
||||
trash = opts.trashLocation
|
||||
if not (trash:find("/$")) then trash = trash .. "/" end
|
||||
|
|
|
|||
Loading…
Reference in New Issue