Commit Graph

204 Commits

Author SHA1 Message Date
93d99aefd3 fix(statuscolumn): fix sign column highlights (#21727)
Resolve #21726.
2023-01-11 09:52:11 +08:00
870ca1de52 feat(float): open float relative to mouse #21531
Problem:
No easy way to position a LSP hover window relative to mouse.

Solution:
Introduce another option to the `relative` key in `nvim_open_win()`.

With this PR it should be possible to override the handler and do something
similar to this https://github.com/neovim/neovim/pull/19481#issuecomment-1193248674
to have hover information displayed from the mouse.

Test case:

    ```lua
    local util = require('vim.lsp.util')

    local function make_position_param(window, offset_encoding)
        window = window or 0
        local buf = vim.api.nvim_win_get_buf(window)
        local row, col

        local mouse = vim.fn.getmousepos()
        row = mouse.line
        col = mouse.column

        offset_encoding = offset_encoding or util._get_offset_encoding(buf)
        row = row - 1
        local line = vim.api.nvim_buf_get_lines(buf, row, row + 1, true)[1]
        if not line then
            return { line = 0, character = 0 }
        end
        if #line < col then
            return { line = 0, character = 0 }
        end

        col = util._str_utfindex_enc(line, col, offset_encoding)

        return { line = row, character = col }
    end

    local make_params = function(window, offset_encoding)
        window = window or 0
        local buf = vim.api.nvim_win_get_buf(window)
        offset_encoding = offset_encoding or util._get_offset_encoding(buf)
        return {
            textDocument = util.make_text_document_params(buf),
            position = make_position_param(window, offset_encoding),
        }
    end

    local hover_timer = nil
    vim.o.mousemoveevent = true

    vim.keymap.set({ '', 'i' }, '<MouseMove>', function()
        if hover_timer then
            hover_timer:close()
        end
        hover_timer = vim.defer_fn(function()
            hover_timer = nil
            local params = make_params()
            vim.lsp.buf_request(
                0,
                'textDocument/hover',
                params,
                vim.lsp.with(vim.lsp.handlers.hover, {
                    silent = true,
                    focusable = false,
                    relative = 'mouse',
                })
            )
        end, 500)
        return '<MouseMove>'
    end, { expr = true })
    ```
2023-01-10 02:22:41 -08:00
87cfe50944 fix(ui): set stc to empty in floatwin with minimal style (#21720)
fix(ui): set stc to emtpy in floatwin with minimal style
2023-01-10 10:36:48 +01:00
e351ab179b fix(ui): add test case 2023-01-09 14:17:32 +08:00
cd6ec1db06 fix(win_close): remove float grid after closing buffer (#21551)
It is not safe to remove the float grid when autocommands can still be
triggered, as autocommands may use the float grid.
2022-12-27 17:29:05 +08:00
ed23cd3e50 fix(float): fix crash with bufpos and non-existent window (#21319) 2022-12-07 11:36:34 +08:00
eab71e7875 test: add more tests for float window bufpos (#21318) 2022-12-07 10:18:12 +08:00
942f26279d fix(tests): only get the color map once, even for multiple test files
Problem: test/functional/ui/screen.lua would be reloaded for each
*_spec.lua file, which causes an extra nvim session to be started
to get the color map each time.

solution: Mark screen.lua as a preloaded file, but defer the
loading of the color map to the first time Screen object is initialised.
2022-11-27 11:51:10 +01:00
e8cc489acc feat(test): add Lua forms for API methods (#20152) 2022-11-14 10:01:35 +00:00
1af4bd04f9 feat(ui): add support to display a title in the border of a float (#20184)
add "title" and "title_pos" keys to win config dict.
2022-11-06 11:59:43 +01:00
14a84ec169 test: add a test for #20684 2022-10-17 21:39:49 +08:00
df646572c5 docs: fix typos (#20394)
Co-authored-by: Raphael <glephunter@gmail.com>
Co-authored-by: smjonas <jonas.strittmatter@gmx.de>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-09-30 09:53:52 +02:00
2083c1771a fix(window): close floats first when closing buffer in other tab (#20284) 2022-09-22 20:25:34 +08:00
00cfc1dceb fix(redraw): avoid unnecessary redraws and glitches with floats+messages
fixes #20106
fixes #20229
2022-09-22 10:36:23 +02:00
79872f3770 fix(options): properly free string options (#19510) 2022-07-27 07:26:32 +08:00
5105f713bd test(float_spec): make indent more consistent 2022-07-10 17:24:29 +08:00
63f6ecd419 fix(float): fix mouse drag position if float window turned to a split 2022-07-10 17:24:29 +08:00
63f63dd2b7 fix(float): fix glitch when making float window with border a split 2022-07-10 17:24:29 +08:00
99e8298711 fix(float): fix float window with winbar cannot have screen height 2022-07-10 17:24:29 +08:00
f7d6f472f7 fix(float): fix float window border drawing with winbar 2022-07-10 17:24:29 +08:00
46536f53e8 feat: add preview functionality to user commands
Adds a Lua-only `preview` flag to user commands which allows the command to be incrementally previewed like `:substitute` when 'inccommand' is set.
2022-05-31 20:55:05 +06:00
f971536f46 fix(mouse): fix mouse drag position with winbar or border in multigrid 2022-05-19 19:16:49 +08:00
17758fe7ad fix(ui): make winbar work with floats and multigrid 2022-05-18 20:16:18 +02:00
bbf58e6bbc refactor(ui)!: link VertSplit to Normal by default
Avoids using `gui=reverse` on `VertSplit` and makes window separators
look much nicer by default.
2022-05-15 22:37:35 +06:00
519e4c4472 test: correct order of arguments to eq() and neq() 2022-04-26 11:38:58 +08:00
a72f338d76 fix(float): do not switch window before deleting last listed buffer (#17840)
Just allow close_windows() to close the current window instead.
This fixes wrong working directory or autocommands not being triggered.
2022-03-24 14:53:20 +08:00
ff82b2785f fix(float): don't always switch window when deleting last listed buffer (#17836) 2022-03-24 11:56:22 +08:00
2e36117840 test: add test for deleting last listed buffer when there are floats (#17833) 2022-03-24 09:28:23 +08:00
a9359dca37 fix(float): make laststatus=1 behave consistently with floating windows 2022-03-23 09:07:21 +08:00
3fdb7b528d fix(float): handle buffer deletion with floating windows 2022-03-23 09:07:21 +08:00
3539456f49 fix(win_close): count the window the be closed instead of curwin 2022-03-23 09:07:21 +08:00
85ae04dbfd fix: close floating windows when calling win_close() 2022-02-10 15:26:40 +00:00
e8631cb8a6 fix(float): skip non-focusable windows for :windo (#15378) 2021-11-11 11:05:18 -07:00
7ff1bc18a9 fix(float): redraw if w_border_adj changed 2021-10-28 06:32:36 +08:00
de670f3809 fix(float): fix potential heap corruption in win_redr_border 2021-10-28 06:32:36 +08:00
810da1a702 fix(mouse): correct dragged position in composed layout 2021-10-04 21:00:42 +02:00
3beea1fe1b Merge pull request #15516 from bfredl/keyset
refactor(api): Represent option dicts as a structs in C and reduce conversion overhead from lua
2021-10-03 14:31:53 +02:00
32565922ef refactor(api): handle option dicts properly
Do not copy a lot of lua strings (dict keys) to just strequal() them
Just compare them directly to a dedicated hash function.

feat(generators): HASHY McHASHFACE
2021-10-03 10:46:57 +02:00
0c06da1f0a fix(nvim_open_win): crash if autocmds delete buffer/window #15549
win_set_buf can trigger autocmds if noautocmd=false. If they close the window,
code afterwards will dereference the freed win_T* wp pointer.

This interaction became possible after commit 1def3d1542.

The reason deleting curbuf crashes, and not the buf passed to
`nvim_open_win`, is because the float initially edits curbuf (`win_init`)
until it's later set to edit buf (windows from `:new` and `:split <buf>`
behave similiarly: approx. `:split`, then `:buffer <buf>`).

`do_buffer` closes windows when their edited buffer is deleted (unless
it's the only window; N/A for floats), so the float closes when curbuf
is deleted, so we need to check `win_valid` after `win_set_buf` too.

Closes #15548
2021-10-02 19:10:59 -07:00
b3e815094b fix(float)!: always anchor to corner of window including border #15832
N, W, S, E are all inclusive, i.e., always anchor to the exact corner of the
window (including border). This line may also need change in this case (change
0 to -1):

This is most consistent and easiest to reason about, especially with GUIs whose
border do not need to have width/height of 1/1 in cell units.

Fix #15789
2021-10-02 17:36:24 -07:00
cd4ec810e9 Merge pull request #14770 from andrew-pa/fix13403
Fix relative float positioning
2021-09-12 09:23:47 +02:00
086631cd92 feat(api): win_viewport also sends line_count #15613 2021-09-10 19:19:39 -07:00
9065730680 fix(windowing): positioning of relative floats
Fix relative floating windows so that they open in the correct position
relative to each other. Also make sure that their positions are correct
immediately after creation without a redraw.
2021-09-08 10:31:47 -06:00
6751d6254b refactor(tests): use assert_alive() #15546 2021-09-01 09:42:53 -07:00
d8ab8cccd0 test: update tests to work with 'hidden' 2021-08-18 12:17:12 -06:00
c8f57f6ded fix(sign): reset auto sign column with minimum in float win minimal style 2021-08-09 11:09:22 +07:00
5f1b728621 fix(api/win_get_config): include z-index 2021-06-19 17:17:17 +01:00
5b6edc852f feat(float): add rounded borders preset
Add `borders = "rounded"` preset for `nvim_open_win`, equivalent to

  border = {"╭", "─", "╮", "│", "╯", "─", "╰", "│"}

Also add undocumented "solid" preset to docs.
2021-06-14 11:10:57 +02:00
8d23941af8 fix(ui): Fix pum incorrect position in multigrid mode
Refs #12985
2021-06-12 14:34:02 +02:00
0cd1430316 Merge pull request #14468 from bfredl/zindex
[WIP] z-index!
2021-05-15 14:44:22 +02:00