-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
163 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Linting and style checking | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
luacheck: | ||
name: Luacheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Prepare | ||
run: | | ||
sudo apt update | ||
sudo apt install -y luarocks | ||
sudo luarocks install luacheck | ||
- name: Lint | ||
run: sudo make lint | ||
|
||
stylua: | ||
name: stylua | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: JohnnyMorganz/stylua-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
args: --color always --check lua/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,4 @@ | ||
# Compiled Lua sources | ||
luac.out | ||
|
||
# luarocks build files | ||
*.src.rock | ||
*.zip | ||
*.tar.gz | ||
|
||
# Object files | ||
*.o | ||
*.os | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
*.def | ||
*.exp | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
doc/tags | ||
.luacheckcache | ||
.luarc.json | ||
*.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Rerun tests only if their modification time changed. | ||
cache = true | ||
|
||
std = luajit | ||
codes = true | ||
|
||
self = false | ||
|
||
-- Glorious list of warnings: https://luacheck.readthedocs.io/en/stable/warnings.html | ||
ignore = { | ||
--[[ | ||
Unused argument, In the case of callback function, | ||
_arg_name is easier to understand than _, | ||
so this option is set to off. | ||
]] | ||
'212', | ||
} | ||
|
||
-- Global objects defined by the C code | ||
read_globals = { | ||
'vim', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
column_width = 78 | ||
line_endings = "Unix" | ||
indent_type = "Spaces" | ||
indent_width = 2 | ||
quote_style = "AutoPreferSingle" | ||
no_call_parentheses = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lint: | ||
luacheck lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,36 @@ | ||
# vfiler-action-yanktree | ||
The yanktree action extension plugin for vfiler.vim. | ||
|
||
This project is an extension plugin for `vfiler.vim` that provides the functionality to copy the filesystem tree structure to the clipboard. This plugin uses the `tree` command internally, so the `tree` command is necessary. | ||
|
||
## Prerequisites | ||
|
||
- Linux or macOS | ||
- `tree` command installed | ||
|
||
## Installation | ||
|
||
Use your favorite plugin manager to install `vfiler-action-yanktree`. For example, if you are using [vim-plug](https://github.com/junegunn/vim-plug), follow the steps below. | ||
|
||
```vim | ||
Plug 'your-github-username/vfiler-action-yanktree' | ||
``` | ||
|
||
## Configuration | ||
|
||
After installation, to configure this plugin as an action in `vfiler.vim`, map the action to your preferred key as shown below. | ||
|
||
```vim | ||
let g:vfiler_config = { | ||
\ 'mappings': { | ||
\ 'your-preferred-key': 'YankTree', | ||
\ } | ||
\} | ||
``` | ||
|
||
## Usage | ||
|
||
Press the configured key to fetch the current directory structure using the `tree` command and copy it to the clipboard. This allows you to easily paste it into other applications. | ||
|
||
## License | ||
|
||
This project is released under the [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
local vim = require('vfiler/libs/vim') | ||
local clipboard = require('vfiler/clipboard') | ||
local core = require('vfiler/libs/core') | ||
|
||
local M = {} | ||
|
||
-- Default configs | ||
M.configs = { | ||
directories_only = false, | ||
options_extened = '', | ||
} | ||
|
||
local function system(dirpath) | ||
local commands = { 'tree' } | ||
if core.is_windows then | ||
if not M.configs.directories_only then | ||
table.insert(commands, '/f') | ||
end | ||
else | ||
if M.configs.directories_only then | ||
table.insert(commands, '-d') | ||
end | ||
end | ||
if #M.configs.options_extened > 0 then | ||
table.insert(commands, M.configs.options_extened) | ||
end | ||
table.insert(commands, ('"%s"'):format(dirpath)) | ||
return core.system(table.concat(commands, ' ')) | ||
end | ||
|
||
function M.yank_tree_root(vfiler, context, view) | ||
if vim.fn.executable('tree') ~= 1 then | ||
core.message.warning("The 'tree' command is requrired to run this.") | ||
return | ||
end | ||
local path = context.root.path | ||
clipboard.yank(system(path)) | ||
core.message.info('Yanked "%s" tree', path) | ||
end | ||
|
||
function M.yank_tree(vfiler, context, view) | ||
if vim.fn.executable('tree') ~= 1 then | ||
core.message.warning("The 'tree' command is requrired to run this.") | ||
return | ||
end | ||
local item = view:get_item() | ||
if not item then | ||
return | ||
end | ||
local path = item.path | ||
if not core.path.is_directory(path) then | ||
path = item.parent.path | ||
end | ||
clipboard.yank(system(path)) | ||
core.message.info('Yanked "%s" tree', path) | ||
end | ||
|
||
--- Setup configs | ||
---@param configs table | ||
function M.setup(configs) | ||
core.table.merge(M.configs, configs) | ||
return M.configs | ||
end | ||
|
||
return M |