Comments (10)
Just to confirm my suspicion: the built-in completion () also doesn't work with GUI popups if I create an identifier of huge length (on my resolution and font that's around 450 characters)
from neovim-gtk.
I decided to try hacking into the code to see if I could solve the problem(which I did). However, what I did isn't generic enough(It works only with YCM because it has 4 columns for autocomplete). I'm using the following:
for line in menu {
let mut line_array = Vec::new();
let max_col_length = [100, 5, 40, 0];
let mut i = 0;
for &item in line {
let (short, _) =
if item.len() > max_col_length[i]
{ item.split_at(max_col_length[i]) }
else
{ (item, "") };
line_array.push(short);
i = i + 1;
}
let larr : Vec<&glib::ToValue> =
line_array.iter().map(|v| v as &glib::ToValue).collect();
list_store.insert_with_values(None, &all_column_ids, &larr[..]);
}
Of course, this ignores the fourth column completely, because I personally don't need it. If you want to fix this in the code, then maybe there should be a maximum width based on width width and font, then add columns until we fill this size(not like the constants in the beginning). I also believe there will be a better way to write this, it is actually my first rust code :) anyway, a great app π
from neovim-gtk.
Limitation of column widths is better do with cell renderers instead of cutting column content, as renderers provide some visual feedback to user that content is bigger than displayed.
Good solution for this issue can be to enable horizontal scroll with some maximum popup window width. Also replace column kind with icon and maybe display column info in some separate popup or add some special info panel to this popup that display info only for selected item.
from neovim-gtk.
Some steps to fix the problem: enable horizontal scroll with maximum width of popup set to bit smaller than window width. Also extract info column to label under popup.
I don't know is there option in neovim to set exact column widths? Maybe introduce new one just for NeovimGtk...
from neovim-gtk.
@daa84 Thanks, this resolves the pop-up being too big. However, it would be ideal to have option to set individual column maximum and to disable the label in this case(because I would like to see member fields' type right next to their names). I'm not aware of such functionality in neovim, but IMHO it will be a great addition to NeovimGtk. At least we can introduce some limit for the "word" column based on font size or some better heuristic so that we can see the "kind" at least. Probably possible with the GtkTreeView sizing policy(https://developer.gnome.org/gtk3/stable/GtkTreeViewColumn.html#gtk-tree-view-column-set-sizing for the C function, possibly there is some equivalent for Rust)
from neovim-gtk.
Added some calculation, so word and kind column must be always visible. Can't say what to do with label, maybe some NeovimGtk specific option.
from neovim-gtk.
This seems to work, thanks π
Another suggestion in relation to this issue - when there is a kind column, don't try to take up all the space(resizing at max_width). What I mean is that for example in the following:
The word column in this particular case(because all "words" are much shorter than the window width) can be made much smaller and this would allow the menu/label/whatever column to be visible as well. This is as simple as the following snippet(maybe should be rewritten if you decide to implement it this way):
if kind_chars > 0 {
layout.set_text("[v]");
let (kind_width, _) = layout.get_pixel_size();
let max_line = menu.iter().max_by_key(|m| m.word.len()).unwrap();
layout.set_text(max_line.word);
let (word_need_width, _) = layout.get_pixel_size();
let word_max_width = max_width - kind_width;
let word_width = min(word_max_width, word_need_width + xpad * 2 + DEFAULT_PADDING);
self.word_column.set_fixed_width(word_width);
self.kind_column.set_fixed_width(kind_width + xpad * 2 + DEFAULT_PADDING);
self.kind_column.set_visible(true);
}
from neovim-gtk.
Also about label: maybe there should be a neovim-gtk specific option. I actually patch nvim-gtk so I don't see it because I don't like how it changes the height of the popup, but I figure that some people would find it really useful and even necessary.
from neovim-gtk.
Ups, yes, width calculation a was wrong, fixed.
from neovim-gtk.
Works like a charm. Now, I "remembered" something which would be a good indicator whether to show the label:
set completeopt-=preview
I have this in my init.vim. Basically, what nvim-gtk displays in the label is what terminal neovim shows in a split preview window. Using the option above I can disable the preview window, so it seems logical that it should also disable the label(I checked and nvim-gtk doesn't show preview at all anyway, regardless of whether I add preview to completeopt or not).
from neovim-gtk.
Related Issues (20)
- argc() not work in vimrc
- Add support to strikethrough text
- Underlines and undercurls are not rendered correctly
- Floating point issues cause gaps in background occasionally
- Characters aren't being drawn sometimes HOT 4
- Characters disappear when NERDTree pane opens HOT 5
- Chinese font width error
- Could not initialize nvim
- Character rendering broken with varying word lengths combined with wrapping HOT 7
- update wiki to include cursor blinking as an option HOT 1
- guisp ignored for underline
- Exits successfully with :cq
- Helping out with maintanence? HOT 10
- Artifact for Windows not Found HOT 1
- Improvement: Popup menu go below current line
- Impossible to install neovim-gtk on Ubuntu 22.04 (dependency problem with package 'fragile') HOT 2
- NGShowProjectView doesnβt do anything when NVIM_GTK_NO_HEADERBAR=1 HOT 1
- Feature request: open multiple tabs with -p
- Crash when trying to middle-click-paste if clipboard is empty
- Please create a way to send monetary contribution
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 neovim-gtk.