Comments (11)
@tamago324 Amazing plugin, happily replaced dirvish with lir. I also have couple of thoughts:
- One thing I am missing is ability to place float window where I want to. Would you mind exposing
col
androw
fromlir.nvim/lua/lir/float/init.lua
Lines 44 to 45 in 504981b
Another possibility would be to allow users to pass in function that creates floating window, like in fzf:
vim.g.fzf_layout = { window = "lua require('utils').floatingLow()" }
- You are computing border's highlight group
lir.nvim/lua/lir/float/init.lua
Lines 13 to 17 in 504981b
I would suggest removing that function, removing LirFloatBorder
highlight group altogether and just set default allowing users to pass in their own. Once again, I might just have enough lua knowledge to come up with PR.
- Would love to have your new_file custom function distributed. I am yet to get it work locally, but it is what I am used to in nvim-tree and it is big improvement in my opinion.
Once again, great plugin, thanks for all your work on it!
from lir.nvim.
With the new PR, we can dynamically calculate the position of the floating window. This allows us to do something like this:
lir_floating_win.mov
Config for the above:
local api = vim.api
-- Construct the Lir floating window options according to the window we are
-- currently in. The position of the window will be centered in the current
-- window, thus not blocking other windows if opened.
---@return table<string, any>
local function construct_win_opts()
local winpos = api.nvim_win_get_position(0)
local winwidth = api.nvim_win_get_width(0)
local winheight = api.nvim_win_get_height(0)
local width = math.min(80, winwidth - 14)
local height = winheight - 6
local row = (winheight / 2) - (height / 2) - 1
local col = (winwidth / 2) - (width / 2)
return {
width = width,
height = height,
row = row + winpos[1],
col = col + winpos[2],
}
end
lir.setup {
float = {
win_opts = construct_win_opts,
}
}
from lir.nvim.
I believe this issue can be closed as most of the features have been implemented. If you want to keep it open, please feel free to reopen it 😄
Thanks everyone for their ideas and suggestions 👍
from lir.nvim.
Thank you for the suggestion!
I will share my thoughts below.
For floating window:
- Provide additional options like width_percentage/height_percentage. This will allow configuration to make the window have more height then width, as most of the space is just empty.
I agree.
My idea is to implement it so that it can be specified as size_percentage = 0.5
or size_percentage = { width = 0.5, height = 0.7 }
. What do you think?
The advantage of being able to specify width and height in this way is that you can explicitly specify width and height only when you want to specify them separately.
It also allows you to use the current option values.
- Option to enable file details like ls -l/Telescope file_browser and ability to toggle them in the buffer similar to show_hidden_files/actions.toggle_show_hidden
I don't think it is necessary because I like the simplicity of the current display.
However, I am curious to see how it will be displayed and implemented.
Do you have a screen capture or something?
- Update implementation for newfile to be similar to that of mkdir. Currently, newfile opens the buffer with the filename, but does not actually create the file unless we save the buffer.
I think it is fine as it is now.
I would like to keep the default implementation of new_file in lir.nvim concise and let users implement it freely.
In fact, I use my own implementation of it.
I agree.
I would like to specify nowait
directly in the mapping.
If there are any problems in the future, I may make it possible to specify it as in gitsign.nvim
.
Delete the buffer when deleting files/directories, similar to how vim-eunuch does with :Delete: Delete a buffer and the file on disk simultaneously. or maybe provide two options, again similar to vim-eunuch: (1) To delete both buffer and file, (2) To only delete the file (already provided)
I agree.
I would like to have two actions like in vim-eunuch.
Currently, actions.delete() is the implementation of (2).
What do you think would be a good action name for (1)?
from lir.nvim.
Thanks for taking a look at all of them, appreciate it :)
My idea is to implement it so that it can be specified as
size_percentage = 0.5
orsize_percentage = { width = 0.5, height = 0.7 }
. What do you think?
Yes, this is much better :)
I don't think it is necessary because I like the simplicity of the current display.
However, I am curious to see how it will be displayed and implemented.
Do you have a screen capture or something?
True, I prefer simplicity as well, although I was just curious if something like that would be of interest.
This is what is shown in nnn
terminal file manager:
Mainly what I look for is just permissions and file size, maybe sometimes last modified time but not more than that.
I think it is fine as it is now.
I would like to keep the default implementation of new_file in lir.nvim concise and let users implement it freely.
In fact, I use my own implementation of it.
Understood. I am curious as to what your implementation is like. I have just adopted it from mkdir
but used Path:touch()
instead.
I agree.
I would like to specify nowait directly in the mapping.
If there are any problems in the future, I may make it possible to specify it as in gitsign.nvim.
I'll open a PR for that unless you have already implemented it :)
I agree.
I would like to have two actions like in vim-eunuch.
Currently, actions.delete() is the implementation of (2).
What do you think would be a good action name for (1)?
How about actions.remove()
? Others could be: destroy
(too much lol), clean
, wipeout
(similar to bufwipeout
). This should be properly documented and maybe put in the README as it might be confusing at first.
While writing this, I got another idea 💡
The floating window should be opened centered as per the current window. So, if there are splits, lir
floating window will be opened in the current window. Actually, this does not seem like that of a great idea, but just putting out here in case someone likes this :)
It would be similar to the screenshot in this issue although that is a tmux pane.
from lir.nvim.
Yes, this is much better :)
Thank you for the pull request.
True, I prefer simplicity as well, although I was just curious if something like that would be of interest.
- This is what is shown in nnn terminal file manager:
- And this is in Telescope file_browser:
Mainly what I look for is just permissions and file size, maybe sometimes last modified time but not more than that.
I see!
I'm not sure if that display can be implemented, but I'm interested.
Understood. I am curious as to what your implementation is like. I have just adopted it from mkdir but used Path:touch() instead.
Thanks for understanding.
My new_file implementation:
It has the following useful features.
- If the input value ends with
'/'
, the directory will be created and - If the input value contains
'/'
, and the directory does not exist, it will be created recursively - If the input file name does not contain
'.'
or'/'
, check if it is a directory. - If the first string is
'.'
andshow_hidden_files
isfalse
, set it totrue
and display it again.
local no_confirm_patterns = {
'^LICENSE$',
'^Makefile$'
}
local need_confirm = function(filename)
for _, pattern in ipairs(no_confirm_patterns) do
if not filename:match(pattern) then
return true
end
end
return false
end
local function newfile()
local save_curdir = vim.fn.getcwd()
lcd(lir.get_context().dir)
local name = vim.fn.input('New file: ', '', 'file')
lcd(save_curdir)
if name == '' then
return
end
if name == '.' or name == '..' then
utils.error('Invalid file name: ' .. name)
return
end
-- If I need to check, I will.
if need_confirm(name) then
-- '.' is not included or '/' is not included, then
-- I may have entered it as a directory, I'll check.
if not name:match('%.') and not name:match('/') then
if vim.fn.confirm("Directory?", "&No\n&Yes", 1) == 2 then
name = name .. '/'
end
end
end
local path = Path:new(lir.get_context().dir .. name)
if string.match(name, '/$') then
-- mkdir
name = name:gsub('/$', '')
path:mkdir({
parents = true,
mode = tonumber('700', 8),
exists_ok = false
})
else
-- touch
path:touch({
parents = true,
mode = tonumber('644', 8),
})
end
-- If the first character is '.' and show_hidden_files is false, set it to true
if name:match([[^%.]]) and not config.values.show_hidden_files then
config.values.show_hidden_files = true
end
actions.reload()
-- Jump to a line in the parent directory of the file you created.
local lnum = lir.get_context():indexof(name:match('^[^/]+'))
if lnum then
vim.cmd(tostring(lnum))
end
e
I'll open a PR for that unless you have already implemented it :)
I've merged! Thank you!
How about actions.remove() ? Others could be: destroy (too much lol), clean, wipeout (similar to bufwipeout). This should be properly documented and maybe put in the README as it might be confusing at first.
Thanks for the suggestions. As for me, I like wipeout()
!
You're right, I need to specify the function in the README.md
and :help
.
While writing this, I got another idea bulb
The floating window should be opened centered as per the current window. So, if there are splits, lir floating window will be opened in the current window. Actually, this does not seem like that of a great idea, but just putting out here in case someone likes this :)It would be similar to the screenshot in this issue although that is a tmux pane.
That sounds kind of interesting.
Also, thanks for putting the idea here.
from lir.nvim.
do you consider render it like a tree. it will make easy to view project structure.
I know it have a reason to not do that but maybe we can have an option
from lir.nvim.
@windwp Thanks for the suggestion.
However, I think you should use nvim-tree.lua to display the tree.
In lir.nvim, I would like to focus only on the display of a single directory.
from lir.nvim.
@gegoune Thank you for the suggestion.
- One thing I am missing is ability to place float window where I want to. Would you mind exposing col and row from
Yes, I would like to be able to set the col and row to user configurable.
I was thinking w passing a function to the float, and then generating a floating window with the options returned by the function (a config-like table that nvim_open_win receives).
require'lir'.setup {
-- ...
float = function()
-- nvim_open_win() の config の値
return {
relative = "editor",
row = 10,
col = 5,
width = math.floor(vim.o.columns * 0,5),
height = math.floor(vim.o.lines * 0.5),
style = "minimal",
border = 'single',
}
end
}
Is it bad to pass a function?
This means that if the user only wants to set row and col, they will have to specify a function.
- You are computing border's highlight group ...
Regarding the border setting, I don't have any trouble with the way it is currently set, but what would it allow me to do if I could set it as you suggest?
- Would love to have your new_file custom function distributed. I am yet to get it work locally, but it is what I am used to in nvim-tree and it is big improvement in my opinion.
Do you want to customize the newfile?
If that's what you mean, then action can be set to any function, so you can map it freely as follows If that's what you mean, you can set a function for action, which can be freely mapped as follows
local lir = require'lir'
local Path = require("plenary.path")
lir.setup({
-- ...
mappings = {
["K"] = function()
local name = vim.fn.input("New file: ", "")
if name == "" then
return
end
local path = Path:new(lir.get_context().dir .. name)
path:touch({
parents = true,
mode = tonumber("644", 8),
})
actions.reload()
end,
}
}
from lir.nvim.
@gegoune PR (#32) was created.
You should now be able to freely configure the floating window config.
Please give it a try and let us know what you think if it is possible.
from lir.nvim.
That's very cool 👏
Also, thank you for providing an example of your setup. I think this will make it easier for other users to configure the settings.
from lir.nvim.
Related Issues (20)
- Add completion for `rename` and move into directory if only a directory is specified.
- Don't show files set in `wildignore` HOT 2
- Make rename behave like linux `mv` HOT 1
- New lir buffer is opened and floating window remains on cd HOT 5
- Add LirCursorLine hightlight HOT 6
- Clipboard action picking up items from previous selection in visual mode (`v`) HOT 4
- `vim.opt.autochdir = true` causing lir to always go one directory up when being toggled in an empty window HOT 2
- Change behavior rename file HOT 1
- [Feature request] Add LSP support HOT 4
- Error using `nvim .` after disabling netrw HOT 3
- ignore option does not work with "dist-newstyle" HOT 1
- Error: Get Filter Error after #5d62e83 commit HOT 2
- Moving up or down directories should visually preserve marked items
- feat: add `../` and `./` to list
- bug: Error detected while processing BufEnter Autocommands for "*": HOT 7
- question: two instances of lir
- Can't use lir.nvim at the same time as oil.nvim HOT 1
- Fullpath contains double slash before filename
- Should be able to give mappings a description (for which-key)
- Devicon colors do not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lir.nvim.