Sublime Forum

Writing an as-minimal-as-feasible plugin with the following features: some questions

#1

Hi guys, I “need-want” to write a “somewhat language-agnostic” plugin to provide (given a simple json-ish spec-of-an-already-existing-language-specific-backend-tooling) a small set of functionality:

  • code completion (disabling built-in word-based completion)
  • “type info” (or “signature”, or simply “whatever info content” given by backend contextually for current symbol) on the fly as the cursor navigates a source file
  • jump to definition (ie gets sorted listing of candidates from said backend)
  • list usage of current symbol
  • ST3 only (someone else may freely turn it into ST2+3 if needed :wink:

Really the driving use-case is to write a sublime “frontend” for Haskell’s ghci (or intero/ghcid) “backend”, but the same pattern comes up in all sorts of languages so after getting the prime use-case running, it should be trivial to somewhat abstract out the general idea: there is for most languages, for each of the above tasks, usually some canonical and robust way to issue the request to a given newly-launched process/command with certain args such that the result will provide a reliably parsable answer.

(Probably still gonna initially focus on ghci/ghcid/intero to start =)

Anyway, main question:

My Python is a bit rusty (been oh 5-6 years! of course I grasp the language basics/essentials/syntax/classes etc), and so the resources I found so far are “a bit overwhelming” and seemingly “all over the place” at first :grin: to smoothly ease into things, what would be the most applicable very minimalist (not totally feature-rich and awash in countless scripts and aux files) tutorial-ish/demo-ish/bare-bones, ST3-first/ready/only plugin repos to look at, scrutinize and play with? Ie. for example something that as the cursor moves around the buffer, just outputs position or current-symbol or some such. Then another that just illustrates running a background process in some sort of non-blocking manner and timing this sanely with respect to the constantly changing cursor location. Do you know of good minimal plugins doing just a small thing well, that small thing being “essentially” (on the ST side of things) the same as what I’ll need to invoke/API-jockey-with?

NB. 1: No need to mention SublimeREPL: even though I initially target ghci/ghcid/intero which are technically REPLs, I’m not talking about the SublimeREPL use-case here, I don’t want to open a REPL window, but fire off processes with specific arguments that turn the “repl” into a “code-base info query tool”.

NB. 2: No need to mention SublimeHaskell: I know of it, but I have my reasons for above-outlined alternative approach (namely if you must know :smile: ghci is always reachable from any Haskell project whereas SH relies on custom/3rd-party tooling to accomplish many of above features that can be messy to set up separately, confusing/dead-end to troubleshoot (ie for Windows users etc), doesn’t utilize the-current-ghc-of-the-current-stack-project etc.)

NB. 3: This isn’t supposed to become my “life project for this decade” so if I won’t manage to make tangible progress within the first 1-2 days or the ST3 API is constantly in flux on a monthly basis (still in beta after all) the endeavour will be abandoned early on. Let me know if you think the above likely. Likewise, if writing ST3 plugins or Python tooling in general is a major hobby of yours and you were looking for a new idea to build out, feel free to run with it (and let us all know!)

0 Likes

#2

Hey metaleap,

I actually began work on a plugin for interfacing with intero a while back, with the eventual goal of abstracting over the back-end and turning it into a generic way to interact with REPLs. :slight_smile: What you’re describing sounds similar. I just made the source code available and you’re welcome to contribute! It was hacked together (I’m not a Python developer either) and is extremely minimal right now (only doing :r for ghcid-style errors on save), so there’s a lot to be done.

TBH, I think such an effort may be subsumed by LSP in future, but it may still be useful for languages which don’t have mature integrations yet.

0 Likes

#3

Awesome, thanks for sharing it just now! Can’t wait to play with that in-depth as soon as I get my current deadline out of the way. LSP sounds like “a good idea in theory” for sure, but if the concept does get adopted widely it’ll be slow going anyway IME. At least for VScode users I guess someone may fork/patch intero to support the protocol.

0 Likes