From 57e115339d00a2a8afe09dba6f83009cc5a02e99 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Mon, 10 Apr 2023 16:38:26 -0300 Subject: nvim update, semi-refactor --- .config/nvim/lua/utils.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .config/nvim/lua/utils.lua (limited to '.config/nvim/lua/utils.lua') diff --git a/.config/nvim/lua/utils.lua b/.config/nvim/lua/utils.lua new file mode 100644 index 0000000..08ff22d --- /dev/null +++ b/.config/nvim/lua/utils.lua @@ -0,0 +1,23 @@ +local M = {} + +function M.lsp_peek() + local params = vim.lsp.util.make_position_params() + return vim.lsp.buf_request(0, 'textDocument/definition', params, + function(_, result, module, _) + if result == nil or vim.tbl_isempty(result) then + vim.lsp.log.info(module, 'No location found') + return nil + end + if vim.tbl_islist(result) then + vim.lsp.util.preview_location(result[1]) + else + vim.lsp.util.preview_location(result) + end + end) +end + +function M.config_home() + return os.getenv('XDG_CONFIG_HOME') or (vim.fn.expand('~') .. '/.config') +end + +return M -- cgit v1.2.3