Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Yakindu lsp #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 53 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"@remixproject/engine": "^0.1.6",
"http-server": "^0.11.1",
"remixd": "0.1.8-alpha.6",
"standard": "^8.5.0"
"standard": "^8.5.0",
"ws": "^7.1.1"
},
"repository": {
"type": "git",
Expand Down
31 changes: 25 additions & 6 deletions src/app/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ const ace = require('brace')

const globalRegistry = require('../../global/registry')
const SourceHighlighters = require('./SourceHighlighters')
const AceLanguageServerService = require('./languageserver')

const Range = ace.acequire('ace/range').Range
require('brace/ext/language_tools')
require('brace/ext/linking')
require('brace/ext/searchbox')
const langTools = ace.acequire('ace/ext/language_tools')
require('ace-mode-solidity/build/remix-ide/mode-solidity')
Expand Down Expand Up @@ -38,7 +40,7 @@ document.head.appendChild(yo`

class Editor {

constructor (opts = {}, themeModule) {
constructor (opts = {}, themeModule) {
// Dependancies
this._components = {}
this._components.registry = globalRegistry
Expand Down Expand Up @@ -72,12 +74,24 @@ class Editor {
json: 'ace/mode/json',
abi: 'ace/mode/json'
}
var languageServer = new AceLanguageServerService()

// Editor Setup
const el = yo`<div id="input"></div>`
this.editor = ace.edit(el)
languageServer.init(this.editor)

ace.acequire('ace/ext/language_tools')
ace.acequire('ace/ext/linking')

//Code Format
this.editor.commands.addCommand({
name: 'format',
bindKey: {win: "Ctrl-Shift-F", mac: "Command-Shift-F"},
exec: function(editor) {
languageServer.format(editor)
}
})

// Unmap ctrl-l & cmd-l
this.editor.commands.bindKeys({
Expand Down Expand Up @@ -118,20 +132,21 @@ class Editor {

this.editor.setOptions({
enableBasicAutocompletion: true,
enableLiveAutocompletion: true
enableLiveAutocompletion: true,
enableLinking: true
})

el.className += ' ' + css['ace-editor']
el.className += ' ' + css['ace-editor']
el.editor = this.editor // required to access the editor during tests
this.render = () => el

// Completer for editor
const flowCompleter = {
getCompletions: (editor, session, pos, prefix, callback) => {
// @TODO add here other propositions
languageServer.completions(this.editor, callback)
}
}
langTools.addCompleter(flowCompleter)
langTools.setCompleters([flowCompleter])

// zoom with Ctrl+wheel
window.addEventListener('wheel', (e) => {
Expand Down Expand Up @@ -163,6 +178,10 @@ class Editor {
e.stop()
})

this.editor.on("linkClick", e => {
languageServer.gotoDefinition(this.editor, e)
});

// Do setup on initialisation here
this.editor.on('changeSession', () => {
this._onChange()
Expand Down
Loading