Git Product home page Git Product logo

lsplinks.nvim's Introduction

LSPLINKS

Support for document links for neovim 0.9+.

Usage

The default behaviour of gx is described in the neovim help as:

Opens the current filepath or URL (decided by <cfile>, 'isfname') at cursor using the system default handler, by calling vim.ui.open().

This plugin extends this behaviour to support LSP document links.

Prerequisites:

An LSP server which supports textDocument/documentLink.

Configuration:

Call setup to initialise the plugin:

local lsplinks = require("lsplinks")
lsplinks.setup()
vim.keymap.set("n", "gx", lsplinks.gx)

Lazy Configuration:

{
    "icholy/lsplinks.nvim",
    config = function()
        local lsplinks = require("lsplinks")
        lsplinks.setup()
        vim.keymap.set("n", "gx", lsplinks.gx)
    end
}

Default Configuration:

lsplinks.setup({
    highlight = true,
    hl_group = "Underlined",
})

Demo 1:

Jump to $ref links in swagger/openapi files.

Demo 2:

Open https://pkg.go.dev from your go.mod or import statements.

lsplinks.nvim's People

Contributors

blackdeer1524 avatar chrisgrieser avatar icholy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lsplinks.nvim's Issues

Doesn't work with attached petstore.yml swagger v2

Placing the cursor over a $ref value and running require("lsplinks").jump() has no effect on this document:

swagger: "2.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
host: petstore.swagger.io
basePath: /v1
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json
paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      tags:
        - pets
      parameters:
        - name: limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          type: integer
          format: int32
      responses:
        "200":
          description: A paged array of pets
          headers:
            x-next:
              type: string
              description: A link to the next page of responses
          schema:
            $ref: '#/definitions/Pets'
        default:
          description: unexpected error
          schema:
            $ref: '#/definitions/Error'
    post:
      summary: Create a pet
      operationId: createPets
      tags:
        - pets
      responses:
        "201":
          description: Null response
        default:
          description: unexpected error
          schema:
            $ref: '#/definitions/Error'
  /pets/{petId}:
    get:
      summary: Info for a specific pet
      operationId: showPetById
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          required: true
          description: The id of the pet to retrieve
          type: string
      responses:
        "200":
          description: Expected response to a valid request
          schema:
            $ref: '#/definitions/Pets'
        default:
          description: unexpected error
          schema:
            $ref: '#/definitions/Error'
definitions:
  Pet:
    type: "object"
    required:
      - id
      - name
    properties:
      id:
        type: integer
        format: int64
      name:
        type: string
      tag:
        type: string
  Pets:
    type: array
    items:
      $ref: '#/definitions/Pet'
  Error:
    type: "object"
    required:
      - code
      - message
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string

Invalid 'col ': out of range

Running the "Organize Imports" quickfix on a Go file with missing imports results in the following error:

Error executing vim.schedule lua callback: ...ly/.local/share/nvim/lazy/lsplinks.nvim/lua/lsplinks.lua:169: Invalid 'col': out of range
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...ly/.local/share/nvim/lazy/lsplinks.nvim/lua/lsplinks.lua:169: in function 'display'
        ...ly/.local/share/nvim/lazy/lsplinks.nvim/lua/lsplinks.lua:150: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp/client.lua:680: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Go Repro:

package main

import (
	"test"
)

func main() {
	os.Exit(1)
}

It's the CursorHold autocmd triggering the failing refresh:

{
  buf = 1,
  event = "CursorHold",
  file = "/tmp/scratch.YYJ7rD/main.go",
  group = 28,
  id = 39,
  match = "/tmp/scratch.YYJ7rD/main.go"
}

Invalid buffer id: 6

Error executing vim.schedule lua callback: ...ly/.local/share/nvim/lazy/lsplinks.nvim/lua/lsplinks.lua:138: Invalid buffer id: 6
stack traceback:
        [C]: in function 'nvim_buf_attach'
        ...ly/.local/share/nvim/lazy/lsplinks.nvim/lua/lsplinks.lua:138: in function 'handler'
        .../github.com/neovim/neovim/runtime/lua/vim/lsp/client.lua:687: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

[Feature Request] - To be able to disable highlight links

Hello, how are you? ๐Ÿ‘‹
I want to congratulate you on this wonderful plugin? ๐Ÿ‘

If it's not too much to ask, I would like to be able to configure this plugin to disable the link highlighting feature in future updates.
The link highlighting is great, but it doesn't look good with my current color scheme. ๐Ÿ™

Another solution could be that the highlight link becomes active when the cursor hovers over it.

Only refresh changed buffers

The CursorHold autocmd refreshes the links even if the buffer wasn't changed. We can maintain a dirty_bufs table which keeps track of which buffers have been modified since the last refresh.

Highlight links

Add support for a display function which highlights links. I think this will mainly be for debugging.

yamlls: is_only_option returns false

The yamlls configuration has definitionProvider and documentLinkProvider capabilities, so is_only_option is returning false. We need a better way to decide if we should use textDocument/definition or textDocument/documentLink requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.