Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial language server protocol implementation #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

prabirshrestha
Copy link

@prabirshrestha prabirshrestha commented Jan 8, 2017

Here is the initial implementation of some of the features of language server protocol (#26)
Currently it only supports 3 method - initialize, textDocument/didOpen, textDocument/documentSymbols as a proof of concept.
This vim plugin is not included in this CR (but if any one wants to try it out let me know and I can share it)

langserver-vim

The implementation is similar to https://github.com/sourcegraph/go-langserver

My next step would be to add support for more of the lsp features and also write a vscode plugin so that I can test with a real client.

Note: I'm not a go dev so this may not be idiomatic go code but feel free to comment.

} else {
return getDocumentSymbols(params, node), nil
}
return nil, nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[govet] reported by reviewdog 🐶
unreachable code

}
return nil, nil
} else {
return nil, errors.New(fmt.Sprintf("% not open", params.TextDocument.URI))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[govet] reported by reviewdog 🐶
unrecognized printf verb 'n'

ProcessID int `json:"processId,omitempty"`
RootPath string `json:"rootPath,omitempty"`
InitializationOptions InitializeOptions `json:"initializationOptions,omitempty"`
Capabilities ClientCapabilities `json:"capabilities",omitempty`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[govet] reported by reviewdog 🐶
struct field tag json:"capabilities",omitempty not compatible with reflect.StructTag.Get: bad syntax for struct tag pair

f, err := NewVimFile(params.TextDocument)
if err != nil {
return nil, err
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
if block ends with a return statement, so drop this else and outdent its block

node, err := f.GetAst()
if err != nil {
return nil, err
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
if block ends with a return statement, so drop this else and outdent its block

return getDocumentSymbols(params, node), nil
}
return nil, nil
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)

}
return nil, nil
} else {
return nil, errors.New(fmt.Sprintf("% not open", params.TextDocument.URI))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...)

"github.com/sourcegraph/jsonrpc2"
)

func NewHandler() jsonrpc2.Handler {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported function NewHandler should have comment or be unexported

type SymbolKind int

const (
SKFile SymbolKind = 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported const SKFile should have comment (or a comment on this block) or be unexported

SKArray SymbolKind = 18
)

type SymbolInformation struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type SymbolInformation should have comment or be unexported

Location Location `json:"location"`
}

type Location struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type Location should have comment or be unexported

Range Range `json:"range"`
}

type Range struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type Range should have comment or be unexported

End Position `json:"end"`
}

type Position struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type Position should have comment or be unexported

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 80.917% when pulling d320a46 on prabirshrestha:langserver-vim into f57a807 on haya14busa:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 80.917% when pulling d320a46 on prabirshrestha:langserver-vim into f57a807 on haya14busa:master.

@haya14busa
Copy link
Member

Thanks @prabirshrestha ! It looks interesting. I will check it later soon.

}
return getDocumentSymbols(params, node), nil
}
return nil, fmt.Errorf("% not open", params.TextDocument.URI)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[govet] reported by reviewdog 🐶
unrecognized printf verb 'n'

Trace string `json:"trace,omitempty"`
}

type InitializeOptions struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type InitializeOptions should have comment or be unexported

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 81.005% when pulling 3351ff2 on prabirshrestha:langserver-vim into f57a807 on haya14busa:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 81.005% when pulling 3351ff2 on prabirshrestha:langserver-vim into f57a807 on haya14busa:master.

Trace string `json:"trace,omitempty"`
}

type InitializeOptions struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[golint] reported by reviewdog 🐶
exported type InitializeOptions should have comment or be unexported

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 81.005% when pulling 2fc51de on prabirshrestha:langserver-vim into f57a807 on haya14busa:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.4%) to 81.005% when pulling 2fc51de on prabirshrestha:langserver-vim into f57a807 on haya14busa:master.

@natebosch
Copy link

Is there any chance of this getting revived? It would be awesome to have a language server for viml!

@prabirshrestha
Copy link
Author

@natebosch I believe @haya14busa is still waiting on me to fix lint issues. I haven't been able to have a look at this yet but if you are interested I would be more than happy to give you write access to my repo so that the issues can be addressed first.

@mattn
Copy link
Member

mattn commented Jan 14, 2019

Any update on this?

@prabirshrestha
Copy link
Author

No updates from my side. Bit more details at here. #26

I do write vimscript a lot so if someone is willing to take this further I would be glad to help out.

@mattn
Copy link
Member

mattn commented Jan 22, 2019

I implemented completion for v: constants.

terminal6

@haya14busa If you don't have enough time to do this, I can add some features to integrate to Vim script.

@mattn
Copy link
Member

mattn commented Feb 5, 2019

@prabirshrestha I created efm-langserver that is based on your langserver and haya14busa's errorformat. Thanks.

https://github.com/mattn/efm-langserver

@prabirshrestha
Copy link
Author

Haven't tried it but this does seem promising. https://github.com/iamcco/vim-language-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants