zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
47.08k stars 2.71k forks source link

Go to Definition Shows Type Definition AND function definition #14060

Closed mikecfisher closed 2 months ago

mikecfisher commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I have a React typescript project and when I press g + d Zed turns into search and shows me the React component I defined but also the type from node_modules/@types/react however if I do g + D it just shows me the type as expected.

I'm assuming that go to definition would just show the function not the type unless I'm missing something.

Environment

Zed: v0.142.5 (Zed) OS: macOS 14.5.0 Memory: 32 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log


notpeter commented 2 months ago

The default vim keybinds are:

https://github.com/zed-industries/zed/blob/89fbd6528f688cc98eaa4b3002f4b41da6c7b520/assets/keymaps/vim.json#L90-L92

https://github.com/zed-industries/zed/blob/89fbd6528f688cc98eaa4b3002f4b41da6c7b520/assets/keymaps/vim.json#L104-L104

If you'd prefer these to be mapped differently, you can redefine them in your ~/.config/zed/keymap.json however you'd like:

[
  {
    "context": "VimControl && !menu",
    "bindings": {
       "g shift-d": "editor::GoToImplementation",
       "g cmd-d": "editor::GoToTypeDefinition"
    }
  }
]

If that doesn't work or if I've misunderstood, let me know and I'm happy to reopen.

vjdhanota commented 1 month ago

@mikecfisher Did you ever figure out a solve for this? I am running into the same issue. "go to definition"/g d is showing both the type in node_modules/@types/react and the definition I am looking for. This becomes annoying as it opens up a new pane item for Definitions of ....

mikecfisher commented 1 month ago

So it did start working for me, but I don't remember making any changes, it just magically corrected itself. Here is my zed config if that helps.

{
  "assistant": {
    "version": "1",
    "provider": {
      "default_model": "claude-3-5-sonnet",
      "name": "anthropic"
    }
  },
  "telemetry": {
    // Enable metrics for telemetry.
    "metrics": true
  },
  "features": {
    // Inline completion provider configuration.
    "inline_completion_provider": "supermaven"
  },

  // List of language servers to use.
  "language_servers": ["vtsls", "eslint"],
  "language_server_options": {
    // Configuration for vtsls server.
    "vtsls": {
      "language_ids": [
        // Supported language IDs.
        "typescript",
        "javascript",
        "typescriptreact",
        "javascriptreact"
      ]
    },
    // Configuration for typescript-language-server.
    "typescript-language-server": {
      "language_ids": [
        "typescript",
        "javascript",
        "typescriptreact",
        "javascriptreact"
      ],
      "initialization_options": {
        "preferences": {
          // Typescript language server preferences.
          "includeInlayParameterNameHints": "all",
          "includeInlayParameterNameHintsWhenArgumentMatchesName": true,
          "includeInlayFunctionParameterTypeHints": true,
          "includeInlayVariableTypeHints": true,
          "includeInlayVariableTypeHintsWhenTypeMatchesName": false,
          "includeInlayPropertyDeclarationTypeHints": true,
          "includeInlayFunctionLikeReturnTypeHints": true,
          "includeInlayEnumMemberValueHints": true
        }
      }
    },
    // Configuration for ESLint server.
    "eslint": {
      "language_ids": [
        "typescript",
        "javascript",
        "typescriptreact",
        "javascriptreact"
      ],
      "initialization_options": {
        // Enable ESLint formatter.
        "run_formatter": true
      }
    }
  },
  "languages": {
    "TypeScript": {
      "formatter": "prettier",
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      },
      "format_on_save": "on"
    },
    "TSX": {
      "formatter": "prettier",
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      },
      "format_on_save": "on"
    },
    "JavaScript": {
      "formatter": "prettier",
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      },
      "format_on_save": "on"
    }
  },
  "formatter": {
    "code_actions": {
      // ESLint fix code actions.
      "source.fixAll.eslint": true
    }
  },
  "tabs": { "file_icons": true },
  "relative_line_numbers": true,
  "theme": "Catppuccin Macchiato",
  "buffer_font_size": 15,
  "buffer_font_family": "FuraCode NF",
  "vim_mode": true,
  "format_on_save": "on",
  "indent_guides": {
    // Render indent guides.
    "render": true,
    // Character used for indent guides.
    "character": "│",
    // Include the first level of indentation.
    "skip_first_level": false
  },
  "project_panel": {
    // Show file icons in project panel.
    "git_status": true,
    "indent_size": 10,
    "file_icons": true
  },
  "terminal": {
    "font_family": "FuraCode NF",
    "font_size": 15
  },
  "vim": {
    // Use multiline registers in Vim mode.
    "use_multiline_registers": true,
    // Enable surround plugin for Vim mode.
    "surround": true,
    // Enable sneak plugin for Vim mode.
    "sneak": true
  },
  "line_numbers": true
}