diff options
| author | christianchiarulli <[email protected]> | 2021-08-11 16:33:41 -0400 | 
|---|---|---|
| committer | christianchiarulli <[email protected]> | 2021-08-11 16:33:41 -0400 | 
| commit | 83013c0d4f1467f546c38719c61909decfcb8151 (patch) | |
| tree | 143773ea73c64d953db699e6e621926e44653fc2 /lua/lsp/service.lua | |
| parent | f6407e0bdb9c2875bc8f186929ce183af391b2a9 (diff) | |
| parent | 5a7630cac761e91335d2f25cb07a81271569c791 (diff) | |
Merge branch 'rolling' of github.com:ChristianChiarulli/LunarVim
Diffstat (limited to 'lua/lsp/service.lua')
| -rw-r--r-- | lua/lsp/service.lua | 122 | 
1 files changed, 0 insertions, 122 deletions
| diff --git a/lua/lsp/service.lua b/lua/lsp/service.lua deleted file mode 100644 index 0c49bacd..00000000 --- a/lua/lsp/service.lua +++ /dev/null @@ -1,122 +0,0 @@ -local M = {} - -local function lsp_highlight_document(client) -  if lvim.lsp.document_highlight == false then -    return -- we don't need further -  end -  -- Set autocommands conditional on server_capabilities -  if client.resolved_capabilities.document_highlight then -    vim.api.nvim_exec( -      [[ -      hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 -      hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 -      hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 -      augroup lsp_document_highlight -        autocmd! * <buffer> -        autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() -        autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() -      augroup END -    ]], -      false -    ) -  end -end - -function M.lsp_highlight_document(client) -  lsp_highlight_document(client) -end - --- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/ -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, { border = lvim.lsp.popup_border }) -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.PeekDefinition() -  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 - -function M.PeekTypeDefinition() -  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/typeDefinition", params, M.preview_location_callback) -  end -end - -function M.PeekImplementation() -  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/implementation", params, M.preview_location_callback) -  end -end - -function M.common_on_attach(client, bufnr) -  if lvim.lsp.on_attach_callback then -    lvim.lsp.on_attach_callback(client, bufnr) -  end -  lsp_highlight_document(client) -end - -function M.no_formatter_on_attach(client, bufnr) -  if lvim.lsp.on_attach_callback then -    lvim.lsp.on_attach_callback(client, bufnr) -  end -  lsp_highlight_document(client) -  client.resolved_capabilities.document_formatting = false -end - -function M.common_capabilities() -  local capabilities = vim.lsp.protocol.make_client_capabilities() -  capabilities.textDocument.completion.completionItem.snippetSupport = true -  capabilities.textDocument.completion.completionItem.resolveSupport = { -    properties = { -      "documentation", -      "detail", -      "additionalTextEdits", -    }, -  } -  return capabilities -end - -return M | 
