diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-10-17 21:26:40 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-10-17 21:26:40 +0200 |
| commit | 54a7c1bf02da30c353ddb4af51b065d895801f47 (patch) | |
| tree | 08dfaa302a7c7018d0dc03fe00518c8129c87c7b /.config/nvim/lua/plugins/scripts/lsp-ext.lua | |
| parent | 1938838a043b13169a550af5ea37239adfc75293 (diff) | |
| parent | c3c0307c2fc26410249df9578c7bf16eb0caa9df (diff) | |
| download | dotfiles-54a7c1bf02da30c353ddb4af51b065d895801f47.tar.gz dotfiles-54a7c1bf02da30c353ddb4af51b065d895801f47.zip | |
Merge commit '67d475c7259bf2448fa3f1d330885ea88036668d'
Diffstat (limited to '.config/nvim/lua/plugins/scripts/lsp-ext.lua')
| -rw-r--r-- | .config/nvim/lua/plugins/scripts/lsp-ext.lua | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/.config/nvim/lua/plugins/scripts/lsp-ext.lua b/.config/nvim/lua/plugins/scripts/lsp-ext.lua deleted file mode 100644 index c4378c6..0000000 --- a/.config/nvim/lua/plugins/scripts/lsp-ext.lua +++ /dev/null @@ -1,48 +0,0 @@ --- --- lsp-ext.lua - - -M = {} - -function M.preview_location(location, context, before_context) - -- location may be LocationLink or Location (more useful for the former) - context = context or 15 - before_context = before_context or 0 - local uri = location.targetUri or location.uri - if uri == nil then - return - end - local bufnr = vim.uri_to_bufnr(uri) - if not vim.api.nvim_buf_is_loaded(bufnr) then - vim.fn.bufload(bufnr) - end - local range = location.targetRange or location.range - local contents = - vim.api.nvim_buf_get_lines(bufnr, range.start.line - before_context, range["end"].line + 1 + context, false) - local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") - return vim.lsp.util.open_floating_preview(contents, filetype) -end - -function M.preview_location_callback(_, method, result) - local context = 15 - if result == nil or vim.tbl_isempty(result) then - print("No location found: " .. method) - return nil - end - if vim.tbl_islist(result) then - M.floating_buf, M.floating_win = M.preview_location(result[1], context) - else - M.floating_buf, M.floating_win = M.preview_location(result, context) - end -end - -function M.peek_definition() - if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then - vim.api.nvim_set_current_win(M.floating_win) - else - local params = vim.lsp.util.make_position_params() - return vim.lsp.buf_request(0, "textDocument/definition", params, M.preview_location_callback) - end -end - -return M |
