Kaynağa Gözat

nixpkgs/neovim: implement _typescript.rename handler

Thomas Dy 2 hafta önce
ebeveyn
işleme
2d7f3ad9a7
1 değiştirilmiş dosya ile 16 ekleme ve 1 silme
  1. 16 1
      .config/nixpkgs/neovim/lsp.lua

+ 16 - 1
.config/nixpkgs/neovim/lsp.lua

@@ -42,7 +42,22 @@ else
     handlers = {
       ['$/typescriptVersion'] = function(err, result, ctx, config)
         vim.notify(string.format('Typescript %s', result.version))
-      end
+      end,
+
+      -- handler used with extract type to interface, etc which asks to rename
+      -- the newly created type
+      ['_typescript.rename'] = function(err, result, ctx)
+        local client = vim.lsp.get_client_by_id(ctx.client_id)
+        vim.lsp.util.show_document({
+          uri = result.textDocument.uri,
+          range = {
+            start = result.position,
+            ['end'] = result.position,
+          }
+        }, client.offset_encoding)
+        vim.lsp.buf.rename()
+        return result
+      end,
     },
     flags = {
       debounce_text_changes = 150,