├── LICENSE ├── README.md ├── doc └── floating_tag_preview.txt ├── lua ├── floating_tag_preview.lua └── floating_tag_preview │ ├── auto_commands.lua │ ├── health.lua │ ├── highlight.lua │ ├── tag_command.lua │ └── window.lua └── plugin └── floating_tag_preview ├── auto_commands.vim ├── commands.vim ├── highlights.vim └── mappings.vim /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Thore Weilbier 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NeoVim Floating Tag Preview 2 | 3 | This plugin allows to easily preview tags in a floating window close to the 4 | cursor. It aims to work as a mostly invisible extension to the native preview 5 | functionality. In fact it tries to fill the gap of a still [missing 6 | `previewwindowfunc` option](https://github.com/neovim/neovim/issues/12859). At 7 | its core, it just opens a floating window before the native tag command gets 8 | executed. Because the native commands search first for an already existing 9 | preview window, they just pick up this window. 10 | 11 | Additionally it provides some minor additions to improve the preview 12 | functionality. Such include to automatically close the window on cursor 13 | movement, open folds in the preview and apply highlight to the tag word. All 14 | features are quite generic, so they can be disabled individually but also 15 | can be also completely customized. 16 | 17 | - [Installation](#installation) 18 | - [Usage](#usage) 19 | - [Customization](#customization) 20 | - [Language Server Protocol Integration](#language-server-protocol-integration) 21 | 22 |

23 | Demo GIF 24 |

25 | 26 | --- 27 | 28 | 29 | ## Installation 30 | 31 | Use your favorite plugin manager to install the plugin or use it as [plain 32 | package](https://neovim.io/doc/user/repeat.html#packages). The following 33 | example uses [packer.nvim](https://github.com/wbthomason/packer.nvim) with some 34 | lazy loading: 35 | 36 | ```vim 37 | lua require('packer').use({ 38 | \ 'weilbith/nvim-floating-tag-preview', 39 | \ cmd = {'Ptag', 'Ptselect', 'Ptjump', 'Psearch', 'Pedit' }, 40 | \ }) 41 | ``` 42 | 43 | 44 | ## Usage 45 | 46 | Unfortunately is is not possible to overwrite native commands. As a 47 | compromise, this plugin clones all tag preview related commands with an upper 48 | case `P` version (e.g. `Ptag`, `Ptnext`, `Psearch`, ...). Native mappings 49 | (e.g. `}`) get automatically overwritten to use the floating versions 50 | (can be disabled). Commands or mappings to focus (`P`) or close 51 | (`z`) the preview window manually just work as always. When the cursor 52 | moves, the window closes automatically again. While continue to preview 53 | different tags (or just see the different locations), the same window gets 54 | re-used and remains the same. 55 | 56 | To preview a simple tag just execute `:Ptag ` or type `}` to 57 | preview the word under the cursor. To cycle through the different definitions, 58 | use `:Ptnext`, `Ptprevious` and friends. But also `:Psearch` might be an 59 | interesting entrypoint. 60 | 61 | You can run the plugin's health check to verify that NeoVim version supports 62 | all necessary features (`:checkhealth floating_tag_preview`). Mind that this 63 | does not work if you load the plugin in a lazy manner. 64 | 65 | 66 | ## Customization 67 | 68 | Checkout [the 69 | docs](https://github.com/weilbith/nvim-floating-tag-preview/blob/master/doc/floating_tag_preview.txt) 70 | (`:help floating_tag_preview.txt`) to get further details on how to customize 71 | each single part of the plugin. 72 | 73 | ## Language Server Protocol Integration 74 | 75 | Tags might be an ancient or event obsolete feature of Vim/NeoVim. If you prefer 76 | to use the data of a language server instead, consider to use 77 | [nvim-lsp-smag](https://github.com/weilbith/nvim-lsp-smag). It makes LSP 78 | locations like definitions, declaration, implementation etc. just work as tags. 79 | Using both plugins in combination you can easily preview the definition of a 80 | code object (e.g. a function or class) under the cursor. Cycling through the 81 | previews will show you the definition, implementation etc. (depending on the 82 | configuration). In fact, the demo GIF at the top is using this plugin in 83 | background. 84 | 85 | Thereby this is a minimal plugin which follows a traditional Vim/NeoVim 86 | approach, but combine it with the most recent advanced features. 87 | -------------------------------------------------------------------------------- /doc/floating_tag_preview.txt: -------------------------------------------------------------------------------- 1 | *floating_tag_preview.txt* Preview tags in a floating window 2 | 3 | Author: Thore Weilbier 4 | License: MIT 5 | 6 | ============================================================================== 7 | *floating_tag_preview_table_of_contents* 8 | TABLE OF CONTENTS~ 9 | 10 | Introduction ............................. |floating_tag_preview_introduction| 11 | Usage ........................................... |floating_tag_preview_usage| 12 | Commands ..................................... |floating_tag_preview_commands| 13 | Variables ................................... |floating_tag_preview_variables| 14 | Highlights ................................. |floating_tag_preview_highlights| 15 | 16 | 17 | ============================================================================== 18 | *floating_tag_preview_introduction* 19 | INTRODUCTION~ 20 | 21 | This plugin allows to easily preview tags in a floating window close to the 22 | cursor. It aims to work as a mostly invisible extension to the native preview 23 | functionality. In fact it tries to fill the gap of a still missing 24 | `previewwindowfunc` option. At its core, it just opens a floating window 25 | before the native tag command gets executed. Because the native commands 26 | search first for an already existing preview window, they just pick up this 27 | window. 28 | 29 | Additionally it provides some minor additions to improve the preview 30 | functionality. Such include to automatically close the window on cursor 31 | movement, open folds in the preview and apply highlight to the tag word. All 32 | features are quite generic, so they can be disabled individually but also 33 | can be also completely customized. 34 | 35 | 36 | ============================================================================== 37 | *floating_tag_preview_usage* 38 | USAGE~ 39 | 40 | Unfortunately is is not possible to overwrite native commands. As a 41 | compromise, this plugin clones all tag preview related commands with an upper 42 | case `P` version (e.g. `Ptag`, `Ptnext`, `Psearch`, ...). Native mappings 43 | (e.g. |_}|) get automatically overwritten to use the floating versions 44 | (can be disabled). Commands or mappings to focus (|CTRL-W_P|) or close 45 | (|CTRL-W_z|) the preview window manually just work as always. When the cursor 46 | moves, the window closes automatically again. While continue to preview 47 | different tags (or just see the different locations), the same window gets 48 | re-used and remains the same. 49 | 50 | To preview a simple tag just execute `:Ptag ` or type |CTRL-W_}| to 51 | preview the word under the cursor. To cycle through the different definitions, 52 | use `:Ptnext`, `Ptprevious` and friends. But also `:Psearch` might be an 53 | interesting entrypoint. 54 | 55 | You can run the plugin's health check to verify that NeoVim version supports 56 | all necessary features (`:checkhealth floating_tag_preview`). Mind that this 57 | does not work if you load the plugin in a lazy manner. 58 | 59 | 60 | ============================================================================== 61 | *floating_tag_preview_commands* 62 | COMMANDS~ 63 | 64 | The following commands are cloned and map to their native lower case version: 65 | 66 | - `Ptag` 67 | - `Ptselect` 68 | - `Ptjump` 69 | - `Ptnext` 70 | - `PtNext` 71 | - `Ptprevious` 72 | - `Ptrewind` 73 | - `Ptfirst` 74 | - `Ptlast` 75 | - `Pedit` 76 | - `Psearch` 77 | 78 | 79 | It is not necessary to use all of them to be able to use the floating window 80 | everywhere. The native commands will just pick up the already open floating 81 | preview window right away. So for example it is fine to use `:Ptag ` 82 | and then just |ptnext| right after. 83 | 84 | 85 | ============================================================================== 86 | *floating_tag_preview_variables* 87 | VARIABLES~ 88 | 89 | The following variables can be set to customize the behavior of this plugin. 90 | In case you prefer to use Lua for your configuration, just use 91 | `vim.g.floating_tag_preview_ = ` . Just remember to use proper Lua 92 | syntax for booleans, lists and dictionaries/tables. Most variables can be 93 | changed during runtime to alternate the behavior. Exceptions are annotated. 94 | 95 | |g:floating_tag_preview_auto_closing_events| 96 | 97 | Events which will automatically close the opened floating preview window. 98 | Setting this to an empty list disables the feature. The window can be still 99 | manually closed with |CTRL-W_z|. 100 | 101 | Default:~ 102 | `['CursorMoved', 'WinScrolled']` 103 | 104 | Examples:~ 105 | `[]` 106 | `['CursorMoved', 'WinNew']` 107 | 108 | |g:floating_tag_preview_highlight_tag_word| 109 | 110 | Toggles the feature to apply a highlight to the tag word in the preview 111 | window. The highlighting itself can be customized with the 112 | |FloatingTagPreviewTagWord| highlight group. 113 | 114 | Default:~ 115 | `v:true` 116 | 117 | |g:floating_tag_preview_overwrite_mappings| 118 | 119 | Toggles the automatic re-mapping of native preview tag mappings to use the 120 | new floating command versions. Such include: 121 | 122 | - |CTRL-W_}| 123 | - |CTRL-W_g}| 124 | 125 | This option can't be changed during runtime, but must be set before the 126 | plugin loads. 127 | 128 | Default:~ 129 | `v:true` 130 | 131 | |g:floating_tag_preview_height| 132 | 133 | The target height for the floating window. Could shrink if there is not 134 | enough space neither above nor below the cursor. 135 | 136 | Default:~ 137 | Links to |'previewheight'| option 138 | 139 | Example:~ 140 | `15` 141 | 142 | |g:floating_tag_preview_width| 143 | 144 | The target width of the floating window. Could shrink if there is not enough 145 | space neither to the left nor right side of the cursor. 146 | 147 | Default:~ 148 | Links to |'textwidth'| option or `70` if undefined 149 | 150 | Example:~ 151 | `100` 152 | 153 | |g:floating_tag_preview_border| 154 | 155 | The border to use for the floating window. Checkout the help for 156 | the |nvim_open_win()| API function to get more details for this option. 157 | 158 | Default:~ 159 | `single` 160 | 161 | Examples:~ 162 | `double` 163 | `["╔", "═" ,"╗", "║", "╝", "═", "╚", "║"]` 164 | 165 | |g:floating_tag_preview_window_options| 166 | 167 | Options to apply to the floating window. Only window scoped options do work. 168 | Used in first place to open folds in the preview. The |'previewwindow'| 169 | options must always be set and can't be removed. The window gets opened with 170 | the `minimal` style option. Thereby options like the sign column, numbers 171 | and more get disabled per default. Though they could be manually enabled 172 | again. 173 | 174 | Default:~ 175 | `{ foldlevel: 100 }` 176 | 177 | Examples:~ 178 | `{ numbers: v:true }` 179 | `{ foldlevel: 0, list: v:true }` 180 | 181 | |g:floating_tag_preview_buffer_options| 182 | 183 | Options to apply to new buffers loaded to the preview window. Only buffer 184 | scoped options do work. This only applies for newly loaded buffers. Buffers 185 | that were already opened before do not get affected. The idea is that such 186 | buffers should only exist temporally and then get unloaded again. Therefore 187 | the primary intention of this setting is to hide and unload the buffer again 188 | when the preview closes. 189 | 190 | Default:~ 191 | `{ buflisted: v:false, bufhidden: 'wipe' }` 192 | 193 | Examples:~ 194 | `{ modifiable: v:false }` 195 | `{ swapfile: v:false, spell: v:true }` 196 | 197 | 198 | ============================================================================== 199 | *floating_tag_preview_highlights* 200 | HIGHLIGHTS~ 201 | 202 | |FloatingTagPreviewTagWord| 203 | 204 | Highlight group used to highlight the tag word in the preview window. Can be 205 | disabled with |g:floating_tag_preview_highlight_tag_word|. 206 | 207 | Default:~ 208 | Links to |hl-Search| group 209 | 210 | 211 | ============================================================================== 212 | 213 | vim:tw=78:ts=8:noet:ft=help:norl: 214 | -------------------------------------------------------------------------------- /lua/floating_tag_preview.lua: -------------------------------------------------------------------------------- 1 | local window_utils = require('floating_tag_preview.window') 2 | local highlight_utils = require('floating_tag_preview.highlight') 3 | local tag_command_utils = require('floating_tag_preview.tag_command') 4 | local auto_command_utils = require('floating_tag_preview.auto_commands') 5 | 6 | return function(tag_command_options) 7 | vim.validate({['tag command options'] = { tag_command_options, 'table' }}) 8 | 9 | auto_command_utils.clear_closing_auto_command() 10 | highlight_utils.determine_and_cache_tag_word(tag_command_options.arguments) 11 | 12 | local preview_window_open_options = { 13 | width = vim.g.floating_tag_preview_width or (vim.o.textwidth > 0 and vim.o.textwidth) or 70, 14 | height = vim.g.floating_tag_preview_height or vim.o.previewheight, 15 | border = vim.g.floating_tag_preview_border or 'single', 16 | } 17 | 18 | local preview_window_set_options = vim.g.floating_tag_preview_window_options or { 19 | foldlevel = 100 20 | } 21 | 22 | local window_number = window_utils.open_floating_preview_window( 23 | preview_window_open_options, 24 | preview_window_set_options 25 | ) 26 | 27 | tag_command_utils.execute_command(tag_command_options) 28 | 29 | if vim.g.floating_tag_preview_highlight_tag_word == true then 30 | highlight_utils.highlight_tag_word_in_preview_window(window_number) 31 | end 32 | 33 | local auto_closing_events = vim.g.floating_tag_preview_auto_closing_events or { 34 | 'CursorMoved', 35 | 'WinScrolled', 36 | } 37 | 38 | auto_command_utils.set_closing_auto_command(auto_closing_events) 39 | end 40 | -------------------------------------------------------------------------------- /lua/floating_tag_preview/auto_commands.lua: -------------------------------------------------------------------------------- 1 | local auto_close_command_group_name = 'FloatingTagPreviewAutoClose' 2 | local auto_close_command_options = ' ++once wincmd z' 3 | 4 | local function set_closing_auto_command(event_names) 5 | vim.validate({['auto closing event name'] = { event_names, 'table' }}) 6 | 7 | vim.api.nvim_command('augroup ' .. auto_close_command_group_name) 8 | 9 | for _, event in ipairs(event_names) do 10 | vim.api.nvim_command('autocmd! ' .. event .. auto_close_command_options) 11 | end 12 | 13 | vim.api.nvim_command('augroup END') 14 | end 15 | 16 | local function clear_closing_auto_command() 17 | vim.api.nvim_command('silent! autocmd! ' .. auto_close_command_group_name) 18 | end 19 | 20 | -- Acts on current window and buffer (meant to be called for buffer events). 21 | local function set_options_for_possible_preview_buffer(options) 22 | vim.validate({['preview buffer options'] = { options, 'table' }}) 23 | 24 | local is_preview_window = vim.api.nvim_win_get_option(0, 'previewwindow') 25 | 26 | if is_preview_window then 27 | for name, value in pairs(options) do 28 | vim.api.nvim_buf_set_option(0, name, value) 29 | end 30 | end 31 | end 32 | 33 | return { 34 | clear_closing_auto_command = clear_closing_auto_command, 35 | set_closing_auto_command = set_closing_auto_command, 36 | set_options_for_possible_preview_buffer = set_options_for_possible_preview_buffer, 37 | } 38 | -------------------------------------------------------------------------------- /lua/floating_tag_preview/health.lua: -------------------------------------------------------------------------------- 1 | local required_api_function_names = { 2 | 'nvim_command', 3 | 'nvim_create_buf', 4 | 'nvim_buf_call', 5 | 'nvim_buf_set_option', 6 | 'nvim_buf_add_highlight', 7 | 'nvim_open_win', 8 | 'nvim_win_set_option', 9 | 'nvim_win_get_option', 10 | 'nvim_win_get_cursor', 11 | 'nvim_win_get_buf', 12 | 'nvim_tabpage_list_wins', 13 | } 14 | 15 | -- Return boolean to signal if further check make sense. 16 | local function check_if_basic_api_exists() 17 | vim.health.start("Check that NeoVim's Lua API exists") 18 | 19 | if vim ~= nil and vim.api ~= nil then 20 | vim.health.ok('API exists') 21 | return true 22 | else 23 | vim.health.error("API is missing!") 24 | return false 25 | end 26 | end 27 | 28 | local function check_if_api_is_complete() 29 | vim.health.start('Check that all API is complete') 30 | 31 | local missing_api_function_names = {} 32 | 33 | for _, api_function_name in ipairs(required_api_function_names) do 34 | local api_function = vim.api[api_function_name] 35 | 36 | if api_function == nil or not vim.is_callable(api_function) then 37 | table.insert(missing_api_function_names, api_function_name) 38 | end 39 | end 40 | 41 | if #missing_api_function_names == 0 then 42 | vim.health.ok('All required API functions are available') 43 | else 44 | for _, api_function_name in ipairs(missing_api_function_names) do 45 | vim.health.error( 46 | "Missing API functions: '" .. api_function_name .. "'" 47 | ) 48 | end 49 | end 50 | end 51 | 52 | local function check() 53 | local api_exists = check_if_basic_api_exists() 54 | 55 | if api_exists then 56 | check_if_api_is_complete() 57 | end 58 | end 59 | 60 | return { 61 | check = check, 62 | } 63 | -------------------------------------------------------------------------------- /lua/floating_tag_preview/highlight.lua: -------------------------------------------------------------------------------- 1 | local function save_tag_word_to_cache(word) 2 | vim.validate({['tag word'] = { word, 's' }}) 3 | 4 | vim.g.floating_tag_preview_cached_tag_word = word 5 | end 6 | 7 | local function load_tag_word_from_cache() 8 | return vim.g.floating_tag_preview_cached_tag_word 9 | end 10 | 11 | local function determine_and_cache_tag_word(command_arguments) 12 | vim.validate({['command arguments'] = { command_arguments, 'string', true }}) 13 | 14 | if command_arguments ~= nil and #command_arguments > 0 then 15 | local first_argument = string.gmatch(command_arguments, "%w+")() 16 | save_tag_word_to_cache(first_argument) 17 | end 18 | 19 | -- Else we stick to the last cached word as the command is a follow up for 20 | -- the last one with and argument. (e.g. `Ptnext`) 21 | end 22 | 23 | local function highlight_tag_word_in_preview_window(window_number) 24 | vim.validate({ ['preview window number'] = { window_number, 'number' }}) 25 | 26 | local tag_word = load_tag_word_from_cache() 27 | 28 | if tag_word == nil or #tag_word == 0 then 29 | return 30 | end 31 | 32 | local buffer_number = vim.api.nvim_win_get_buf(window_number) 33 | 34 | vim.api.nvim_buf_call(buffer_number, function() 35 | vim.api.nvim_call_function('search', { tag_word, 'c' }) 36 | end) 37 | 38 | local cursor = vim.api.nvim_win_get_cursor(window_number) 39 | local line = cursor[1] - 1 40 | local column_start = cursor[2] 41 | local column_end = column_start + #tag_word 42 | 43 | vim.api.nvim_buf_add_highlight( 44 | buffer_number, 45 | -1, 46 | 'FloatingTagPreviewTagWord', line, 47 | column_start, 48 | column_end 49 | ) 50 | end 51 | 52 | return { 53 | determine_and_cache_tag_word = determine_and_cache_tag_word, 54 | highlight_tag_word_in_preview_window = highlight_tag_word_in_preview_window, 55 | } 56 | -------------------------------------------------------------------------------- /lua/floating_tag_preview/tag_command.lua: -------------------------------------------------------------------------------- 1 | local function validate_command_options(options) 2 | vim.validate({ ['command options'] = { options, 'table' }}) 3 | vim.validate({ command = { options.command, 'string' }}) 4 | vim.validate({ count = { options.count, 'number', true }}) 5 | vim.validate({ range = { options.range, 'table', true }}) 6 | 7 | if options.range ~= nil then 8 | vim.validate({ ['range.line1'] = { options.range.line1, 'number' }}) 9 | vim.validate({ ['range.line2'] = { options.range.line2, 'number' }}) 10 | end 11 | 12 | vim.validate({ bang = { options.bang, 'string', true }}) 13 | vim.validate({ arguments = { options.arguments, 'string', true }}) 14 | end 15 | 16 | local function execute_command(options) 17 | validate_command_options(options) 18 | 19 | local full_command = options.command 20 | 21 | if options.count ~= nil then 22 | full_command = options.count .. full_command 23 | elseif options.range ~= nil then 24 | full_command = options.range.line1 .. ',' .. options.range.line2 .. full_command 25 | end 26 | 27 | if options.bang ~= nil then 28 | full_command = full_command .. options.bang 29 | end 30 | 31 | if options.arguments ~= nil then 32 | full_command = full_command .. " " .. options.arguments 33 | end 34 | 35 | local success, error_message = pcall(vim.api.nvim_command, full_command) 36 | 37 | if not success then 38 | vim.api.nvim_command('silent! wincmd z') 39 | error(error_message) 40 | end 41 | end 42 | 43 | return { 44 | execute_command = execute_command, 45 | } 46 | -------------------------------------------------------------------------------- /lua/floating_tag_preview/window.lua: -------------------------------------------------------------------------------- 1 | -- The return value of -1 indicates that there is no preview window open. 2 | local function get_preview_window_number() 3 | local all_window_numbers = vim.api.nvim_tabpage_list_wins(0) 4 | 5 | for _, window_number in ipairs(all_window_numbers) do 6 | local is_preview_window = vim.api.nvim_win_get_option(window_number, 'previewwindow') 7 | 8 | if (is_preview_window) then 9 | return window_number 10 | end 11 | end 12 | 13 | return -1 14 | end 15 | 16 | local function set_preview_window_options(window_number, window_options) 17 | vim.validate({['preview window number'] = { window_number, 'number' }}) 18 | vim.validate({['preview window options'] = { window_options, 'table' }}) 19 | 20 | vim.api.nvim_win_set_option(window_number, 'previewwindow', true) 21 | 22 | for name, value in pairs(window_options) do 23 | vim.api.nvim_win_set_option(window_number, name, value) 24 | end 25 | end 26 | 27 | local function open_floating_preview_window(window_open_options, window_set_options) 28 | vim.validate({['preview window open options'] = { window_open_options, 'table' }}) 29 | vim.validate({['window window width'] = { window_open_options.width, 'number' }}) 30 | vim.validate({['window window height'] = { window_open_options.height, 'number' }}) 31 | -- Can not validate border as it can be either string or table. 32 | vim.validate({['preview window set options'] = { window_set_options, 'table' }}) 33 | 34 | local old_window_number = get_preview_window_number() 35 | 36 | if old_window_number ~= -1 then 37 | return old_window_number 38 | end 39 | 40 | local window_options = vim.lsp.util.make_floating_popup_options( 41 | window_open_options.width, 42 | window_open_options.height, 43 | { border = window_open_options.border } 44 | ) 45 | local buffer_number = vim.api.nvim_create_buf(false, true) 46 | local window_number = vim.api.nvim_open_win(buffer_number, false, window_options) 47 | 48 | set_preview_window_options(window_number, window_set_options) 49 | 50 | return window_number 51 | end 52 | 53 | return { 54 | open_floating_preview_window = open_floating_preview_window, 55 | } 56 | -------------------------------------------------------------------------------- /plugin/floating_tag_preview/auto_commands.vim: -------------------------------------------------------------------------------- 1 | augroup FloatingTagPreview 2 | autocmd! 3 | autocmd BufAdd * 4 | \ lua require('floating_tag_preview.auto_commands').set_options_for_possible_preview_buffer( 5 | \ vim.g.floating_tag_preview_buffer_options or { 6 | \ buflisted = false, 7 | \ bufhidden = 'wipe', 8 | \ } 9 | \ ) 10 | augroup END 11 | -------------------------------------------------------------------------------- /plugin/floating_tag_preview/commands.vim: -------------------------------------------------------------------------------- 1 | command! -bang -nargs=1 Ptag lua require('floating_tag_preview')({ command = 'ptag', bang = '', arguments = '' }) 2 | command! -bang -nargs=1 Ptselect lua require('floating_tag_preview')({ command = 'ptselect', bang = '', arguments = '' }) 3 | command! -bang -nargs=1 Ptjump lua require('floating_tag_preview')({ command = 'ptjump', bang = '', arguments = '' }) 4 | command! -count=1 -bang Ptnext lua require('floating_tag_preview')({ command = 'ptnext', count = , bang = '' }) 5 | command! -count=1 -bang PtNext lua require('floating_tag_preview')({ command = 'ptNext', count = , bang = '' }) 6 | command! -count=1 -bang Ptprevious lua require('floating_tag_preview')({ command = 'ptprevious', count = , bang = '' }) 7 | command! -count=1 -bang Ptrewind lua require('floating_tag_preview')({ command = 'ptrewind', count = , bang = '' }) 8 | command! -count=1 -bang Ptfirst lua require('floating_tag_preview')({ command = 'ptfirst', count = , bang = '' }) 9 | command! -bang Ptlast lua require('floating_tag_preview')({ command = 'ptlast', bang = '' }) 10 | command! -bang -nargs=+ Pedit lua require('floating_tag_preview')({ command = 'pedit', bang = '', arguments = '' }) 11 | command! -range -bang -nargs=+ Psearch lua require('floating_tag_preview')({ command = 'psearch', range = { line1 = , line2 = }, bang = '', arguments = '' }) 12 | -------------------------------------------------------------------------------- /plugin/floating_tag_preview/highlights.vim: -------------------------------------------------------------------------------- 1 | highlight default link FloatingTagPreviewTagWord Search 2 | -------------------------------------------------------------------------------- /plugin/floating_tag_preview/mappings.vim: -------------------------------------------------------------------------------- 1 | if !get(g:, 'floating_tag_preview_overwrite_mappings', v:false) 2 | nnoremap } execute 'Ptag ' . expand('') 3 | nnoremap g} execute 'Ptjump ' . expand('') 4 | endif 5 | --------------------------------------------------------------------------------