Skip to content

toziegler/prlsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PRLSP

prlsp is an LSP server for surfacing GitHub PR review comments in-editor (as diagnostics), with commands/code-actions to create replies and new comments.

This repository also ships an Emacs package at emacs/prlsp.el and Neovim plugin at root directory.

Emacs package (emacs/prlsp.el)

The package provides Emacs-side UX helpers (without changing the LSP protocol):

  • prlsp-comment-on-line: open a markdown popup and submit a new review comment
  • prlsp-reply-on-line: open a markdown popup and submit a reply to an existing thread
  • prlsp-show-thread: show full thread content in a markdown side buffer
  • prlsp-mode: minor mode auto-enabled only when the active server is prlsp

No keybindings are installed by default. Bind commands in your config.

straight.el setup

(use-package prlsp
  :straight (:host github :repo "toziegler/prlsp" :files ("emacs/*.el"))
  :init
  ;; Optional customization before setup:
  ;; (setq prlsp-command '("prlsp_go"))
  ;; (setq prlsp-preferred-backend 'lsp) ; or 'eglot
  ;; (setq prlsp-auto-start t)
  :config
  (prlsp-setup))

Example bindings (vanilla Emacs)

(global-set-key (kbd "C-c p c") #'prlsp-comment-on-line)
(global-set-key (kbd "C-c p r") #'prlsp-reply-on-line)
(global-set-key (kbd "C-c p s") #'prlsp-show-thread)

Doom Emacs setup

packages.el

(package! prlsp
  :recipe (:host github :repo "toziegler/prlsp" :files ("emacs/*.el")))

config.el

(use-package! prlsp
  :init
  ;; Optional:
  ;; (setq prlsp-preferred-backend 'lsp)
  ;; (setq prlsp-command '("prlsp_go"))
  :config
  (prlsp-setup)
  (map! 
        :localleader
        (:prefix ("p" . "prlsp")
         :desc "New PR comment" "c" #'prlsp-comment-on-line
         :desc "Reply to thread" "r" #'prlsp-reply-on-line
         :desc "Show thread" "s" #'prlsp-show-thread))
         )

Notes

  • prlsp-setup registers both lsp-mode and eglot integrations.
  • prlsp-preferred-backend only controls which auto-start hooks are added.
  • If you prefer manual startup, set (setq prlsp-auto-start nil) and start your backend yourself.

Neovim plugin

The plugin provides Lua API:

  • require("prlsp").comment_on_line(): open markdown buffer to write a new PR comment on current line
  • require("prlsp").reply_on_line(): open markdown buffer to reply to a PR review thread on current line
  • require("prlsp").show_thread(): show full review thread at current line in markdown side buffer
  • require("prlsp").refresh(): refresh PR review threads

And the equivalent Ex-commands:

  • :PRLSPCommentOnLine
  • :PRLSPReplyOnLine
  • :PRLSPShowThread
  • :PRLSPRefresh

Plugin installation

-- Neovim 0.12+ required
vim.pack.add({ "https://github.com/toziegler/prlsp" })

LSP setup

-- Note: plugin hardcodes prlsp LSP name
vim.lsp.config('prlsp', {
  cmd = { 'prlsp' }, -- Name of LSP executable or path
  root_markers = { '.git' },
})

vim.lsp.enable({'prlsp'})

Keymap binding example

vim.keymap.set('', '<Leader>r', function()
  require('prlsp').reply_on_line()
end)

About

Pull request LSP.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors