danr / kakoune-languageclient

WIP: Language server protocol client for the Kakoune text editor
MIT License
9 stars 0 forks source link

Build fails? #1

Closed jacobdufault closed 6 years ago

jacobdufault commented 6 years ago

I executed the following:

$ git clone https://github.com/danr/kakoune-languageclient
$ cd kakoune-languageclient
$ npm install
$ npm run-script build

> kakoune-languageclient@0.1.0 build /home/jake/kakoune-languageclient
> tsc

src/libkak-example.ts(7,47): error TS2339: Property 'CreateHandler' does not exist on type 'typeof "/home/jake/kakoune-languageclient/src/libkak"'.
src/libkak-example.ts(9,49): error TS2339: Property 'KakouneBuddy' does not exist on type 'typeof "/home/jake/kakoune-languageclient/src/libkak"'.
src/libkak-example.ts(14,38): error TS7006: Parameter 'm' implicitly has an 'any' type.
src/libkak-example.ts(15,42): error TS7006: Parameter 'm' implicitly has an 'any' type.
src/libkak-example.ts(17,46): error TS7006: Parameter 'm' implicitly has an 'any' type.
src/libkak-example.ts(27,56): error TS7006: Parameter 'm' implicitly has an 'any' type.
src/libkak.ts(119,43): error TS2345: Argument of type 'Partial<Record<keyof Splice, string>>[K]' is not assignable to parameter of type 'string'.
  Type 'Record<keyof Splice, string>[K] | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'.
src/main.ts(17,47): error TS2339: Property 'CreateHandler' does not exist on type 'typeof "/home/jake/kakoune-languageclient/src/libkak"'.
src/main.ts(19,49): error TS2339: Property 'KakouneBuddy' does not exist on type 'typeof "/home/jake/kakoune-languageclient/src/libkak"'.
src/main.ts(208,3): error TS7006: Parameter 'm' implicitly has an 'any' type.
src/main.ts(221,3): error TS7006: Parameter 'm' implicitly has an 'any' type.
src/main.ts(234,3): error TS7006: Parameter 'm' implicitly has an 'any' type.

Is the project currently working/building?

jacobdufault commented 6 years ago

If it matters:

$ node --version
v9.5.0
$ npm --version
5.6.0
jacobdufault commented 6 years ago

I'm guessing the definitions got lost in https://github.com/danr/kakoune-languageclient/commit/4e442fba481abfded2d6c48f11ec7cbff3bacc6b (but it looks like that commit is also broken with different compile errors).

danr commented 6 years ago

Yes, this repo is in a mess right now.

Sorry for that, I've been intending for a while to actually make this usable but I haven't gotten around to. I will ping you here when it's usable.

In the meantime you can try this for lsp support in kakoune: https://github.com/danr/libkak

jacobdufault commented 6 years ago

I'm planning on doing some LSP integration so I can use kakoune day to day (I'm the author of cquery). cquery has a bunch of LSP extensions and requires some special treatment (ie, it requires a cacheDirectory argument in initialization options).

Looking over the libkak repo it seems like the approach here is more robust (ie, using the vscode langserver lib). Most likely I'll submit some PRs or I'll write a LSP client myself :)

danr commented 6 years ago

Oh cool, happy to talk to you, cquery looks like a very impressive project!

If I put this in a good shape, would you be comfortable with writing TypeScript? Then we could make sure all your extensions are supported.

On the other hand, if you assume it would be "quick" for you to write a client for kakoune using your current setup, feel free to go for it :)

Regardless of what we choose to do it would be nice to stay in touch, perhaps my experience with kakoune-communication could come in handy, and from my side your knowledge about the protocol (and how other clients implement it) is of course very valuable.

jacobdufault commented 6 years ago

Yep, using typescript is fine, I wrote the cquery vscode extension so I'm already familiar with vscode-languageserver.

I suspect using this package would be faster than me hacking together my own thing, though I'm already considering writing a libkak style library for lua (since I'd like to write any reasonably sophisticated kakoune extension in something other than shell).

Are the CreateHandler and KakouneBody errors from missing code or from incomplete refactorings? I can take a look at fixing if you don't have time, but if they are just from missing code it'd be great if that was uploaded :)

jacobdufault commented 6 years ago

FYI from the latest changes:

$ npm install
$ npm run-script example 34350
> kakoune-languageclient@0.1.0 example /work/packages/kakoune-languageclient
> ts-node src/libkak-example.ts "34350"
/work/packages/kakoune-languageclient/node_modules/ts-node/src/index.ts:307
        throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
              ^
TSError: ⨯ Unable to compile TypeScript
src/libkak.ts (133,43): Argument of type 'Partial<Record<keyof Splice, string>>[K]' is not assignable to parameter of type 'string'.
  Type 'Record<keyof Splice, string>[K] | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'. (2345)
    at getOutput (/work/packages/kakoune-languageclient/node_modules/ts-node/src/index.ts:307:15)
    at /work/packages/kakoune-languageclient/node_modules/ts-node/src/index.ts:336:16
    at Object.compile (/work/packages/kakoune-languageclient/node_modules/ts-node/src/index.ts:498:11)
    at Module.m._compile (/work/packages/kakoune-languageclient/node_modules/ts-node/src/index.ts:392:43)
    at Module._extensions..js (module.js:652:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/work/packages/kakoune-languageclient/node_modules/ts-node/src/index.ts:395:12)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
    at Module.require (module.js:585:17)
danr commented 6 years ago

Yes the main file was in limbo due to refactorings.

Give it a whirl again, I cannot reproduce the type error you have above. Perhaps use yarn instead?

danr commented 6 years ago

I don't think I will be able to attend this before Saturday. There are some nice things to do with the main api: I think it will be possible to make quite a nice api for communicating with kakoune using async/await.

jacobdufault commented 6 years ago

Tried with yarn, still got the same error. Replacing line 133 of libkak.ts fixed the issue:

from

        parsed_rhss[k] = details[k].parse(rhs)

to

        parsed_rhss[k] = details[k].parse(<string>rhs)

I'm not sure if rhs is actually always a string?

danr commented 6 years ago

It will always be a string, and TypeScript should know:

const rhs: string | undefined = parsed_json_line[k]  
if (rhs === undefined) {
  throw 'Missing ' + k
}
// rhs is now a string and not undefined and typescript knows
parsed_rhss[k] = details[k].parse(rhs)

Can you check what typescript version is reported for you on these commands?

[09:04|~/code/kakoune-languageclient] 
$ yarn run tsc --version
yarn run v1.3.2
$ /home/dan/code/kakoune-languageclient/node_modules/.bin/tsc --version
Version 2.7.1
Done in 0.22s.
[09:04|~/code/kakoune-languageclient] 
$ yarn run ts-node --version
yarn run v1.3.2
$ /home/dan/code/kakoune-languageclient/node_modules/.bin/ts-node --version
ts-node v4.1.0
node v9.4.0
typescript v2.7.1
cache "/tmp/ts-node-1de189637a45d92ae768121e9d15cbfee66de8ff0a5075c450b85b1ffdfbf316/78286cd1b159e71a38a4d20f2be8cccbf87f84c798e38298c312a019c2867bdf"
Done in 0.38s.

I am a bit confused though since I thought the entire 2.x line of typescript had this control flow based type analysis implemented: https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#control-flow-based-type-analysis

jacobdufault commented 6 years ago
$ yarn run tsc --version
yarn run v1.3.2
$ /work/packages/kakoune-languageclient/node_modules/.bin/tsc --version
Version 2.7.1
Done in 0.44s.

$ yarn run ts-node --version
yarn run v1.3.2
$ /work/packages/kakoune-languageclient/node_modules/.bin/ts-node --version
ts-node v3.3.0
node v9.2.0
typescript v2.7.1
cache "/tmp/ts-node-598b0a95680b23a0212d62f697866801462582ca0991f582dc26305606830ace/ff0df364894a7aa6f7a73b5f20992a888193db4e88bee8794f2724c8e1744220"
Done in 0.66s.

Looks like my ts-node is older. With the yarn.lock file you committed things seem to work okay now.