danielgavin / ols Goto Github PK
View Code? Open in Web Editor NEWLanguage server for Odin
License: MIT License
Language server for Odin
License: MIT License
This code gets formatted as follows:
package test
Some_Enum :: enum {
Field1 = 0x9,
Field2 = 0xA,
}
@(default_calling_convention = "c")
@(link_prefix = "foobar")
foreign bar {
Foo :: proc() ---
}
The attributes attached to the foreign block cause the enum values to be indented. Commenting out the foreign block and formatting corrects the enum indentation.
make([dynamic] Line, 0, NO_COMPLETION_HERE , context.temp_allocator);
Formatter output:
package test
Some_Enum :: enum {
Field,}
Another_Enum :: enum {
Field = 1,}
Typing a character in two parentheses after proc
, I've only tested !
, %
, &
and *
:
package main
main :: proc((*)) {}
Only got Connection to server got closed.
in the output window
Version: 1.53.0-insider (system setup)
Commit: 32b28f6f8f9dfe36efad102cc460e14a84ba756a
Date: 2021-01-19T06:09:44.762Z
Electron: 11.2.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19041
package main
import €
main :: proc() {
i: int;
}
c:/Odin/Projects/Test/ols.odin(2:4) illegal character '€': 8364
[Error - 20:49:38] Connection to server is erroring. Shutting down server.
Only some types of crash outputs the illegal character
line.
Every crash outputs that the server is erroring.
OLS crashes when a €
is typed after import
OLS won't crash if €
already exists when OLS is started.
If OLS is started after €
is typed, typing another €
crashes it (also with some but not other characters).
If OLS is started after €
is typed, typing "i: in" in main crashes OLS, as soon as n
is typed.
OLS doesn't crash when only typing €
in main
, only when it's in the import
statement.
Maybe this is too specific, but that's the behaviour I saw
foo := 0xFFFF0000 >> 16
gives 'expected an operand'
After adding the new symbols in the indexer, the generic resolving doesn't work any more.
There is an issue with the formatter on if .. do statements:
if true do return
currently formats to:
if truedo return
This will fail to format
package test
Test :: struct {
data: [^]u8,
}
main :: proc() {}
Truncated error message
ols/src/odin/printer/visit.odin(1042:3) panic: Multi_Pointer_Type{node = Expr
Right now the completion gets interrupted when you type 'in', 'context', 'when', etc.
Alias procedures and types are not functioning properly
code that can cause the crash:
package main
add :: proc(a,b : int) -> #force_inline
Hello and thanks for your work on ols!
Sorry for adding this as an issue I didn't know where else to put it and is such a small thing that a full pull request seemed like too much.
I've been testing ols on linux with odin-mode (found in the "odin libs" section of the odin wiki) and lsp-mode. Completion and hovering are working great, goto-definition of functions does make the server crash sometimes, (with exit code "1"), but other than that I haven't had any issues.
So I was wondering if you might like to add emacs to the list of clients in the README file.
If you decide to add it, here's the config:
;; With odin-mode (https://github.com/mattt-b/odin-mode) and lsp-mode already added to your init.el of course!.
(setq-default lsp-auto-guess-root t) ;; if you work with Projectile/project.el this will help find the ols.json file.
(defvar lsp-language-id-configuration '((odin-mode . "odin")))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "/path/to/ols/executable")
:major-modes '(odin-mode)
:server-id 'ols
:multi-root t)) ;; This is just so lsp-mode sends the "workspaceFolders" param to the server.
(add-hook 'odin-mode-hook #'lsp)
Please, let me know if you need any more info.
Cheers!.
package main
main :: proc() {
x : [3]int;
for i := 0; i < len(x); i += 1 {
x := x[i] // Crash
}
}
Connection to server got closed.
Seems to crash as soon as I type the i
index.
OLS: commit 51595ac (newest as of writing this)
Odin: 0.13.1-92431c83
VSCode:
Version: 1.53.1 (system setup)
Commit: 5d424b828ada08e1eb9f95d6cb41120234ef57c7
Date: 2021-02-08T23:29:42.785Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19041
Editor: Visual Studio Code
Input:
package main
debugCallback :: proc "c" (
aaaaaa: string,
bbbb: string,
bbb: string,
ccccccccccc: string,
) -> b32 {
}
Formatted output:
package main
debugCallback :: proc
"c"
(
aaaaaa: string,
bbbb: string,
bbb: string,
ccccccccccc: string,
) -> b32 {
}
I need to refractor the resolve system away from using SymbolGenericValue to specific types:
SymbolDynamicArrayValue,
SymbolFixedArrayValue,
SymbolMapValue,
SymbolSliceValue,
SymbolBasicValue,
SymbolUntypedValue,
This change should make it possible to support procedure overloading correctly.
This bug seems to have been introduced with some of the new odin parser changes.
My_Struct :: struct {
type: int,
a*
indent: int,
width: int,
penalty: f32,
}
Have unions do completion with type cast assertion. ie. my_union.(MyValue)
Was trying to build on the latest odin release but it comes up with a lot of errors, i've tried to go through and fix it myself to make a PR or something, but I don't know odin well enough.
With respect to https://github.com/vassvik/odin-gl, OLS is no longer indexing symbols in https://github.com/vassvik/odin-gl/blob/master/wrappers.odin . No relevant error output from the LS request in VSC. The rest of the symbols from the package seem to be indexing fine.
Right now the static indexer uses a naive approach that is fast enough for now, but as projects get bigger, the static indexer needs to get faster.
It could be a file indexer or an in memory indexer(Maybe allow for choosing the indexer).
In order for ols to index my project's code, I've had to add this entry into collections
in ols.json:
{"name": "", "path": "."}
is this by design? This isn't mentioned in the readme so I'm uncertain if this is a bug or intended.
Missing the "
after the :
in an import statement, though only when there is text between the first "
and :
package main
import "core:
ols.json:
{
"collections": [
{ "name": "core", "path": "C:/Odin/Odin/core/" },
{ "name": "shared", "path": "C:/Odin/Odin/shared/" }
],
"thread_pool_count": 4,
"enable_document_symbols": true,
"enable_semantic_tokens": true,
"enable_hover": true
}
Output window:
C:/Odin/Tools/ols/src/server/documents.odin(415:30) Invalid slice indices: 6:5:6
Version: 1.53.0-insider (system setup)
Commit: 32b28f6f8f9dfe36efad102cc460e14a84ba756a
Date: 2021-01-19T06:09:44.762Z
Electron: 11.2.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Windows_NT x64 10.0.19041
Running the latest commit of ols against one of my projects resulted in LS request failure with error:
Clone type Unhandled node kind: Type_Cast
I made this change
@@ -214,6 +214,10 @@ clone_node :: proc(node: ^ast.Node, allocator: mem.Allocator, unique_strings: ^m
case Helper_Type:
r := cast(^Helper_Type)res;
r.type = clone_type(r.type, allocator, unique_strings);
+ case Type_Cast:
+ r := cast(^Type_Cast)res;
+ r.type = clone_type(r.type, allocator, unique_strings);
+ r.expr = clone_type(r.expr, allocator, unique_strings);
case:
panic(fmt.aprintf("Clone type Unhandled node kind: %T", node.derived));
}
which ultimately allowed the failing LS request to succeed. I'm largely unfamiliar with the purpose of clone_node
and the inner workings of this project, so I do not know if this is a correct implementation for Type_Cast
here, and do not know if in reality this is just a bandaid over a different bug in OLS which resulted in this faulty call.
Is this a valid fix? If so I'll happily move this into a PR, otherwise I felt this would be better as an issue for discussion's sake.
package main
import la "core:math/linalg"
import "core:strings"
main :: proc() {
sb := strings.make_builder_len(la.length);
}
Typing in the name of the length
function to the make_builder_len
function closes the server.
I know that that shouldn't be the parameter to that function, but I was preemptively putting a length variable as the argument before the variable was declared, so it used the length function instead.
Implement dynamic indexer that runs in a background that can index modified files in clients workspace.
Right now the LSP just shows the procedure signature, but it should also underline which argument it currently is at.
Just a quick note that ols fails to build with Odin as of April 22, 2021 at 21:31 MST. I reverted back to commit 2db1fe74299766c9a29a33c39299d07e12556bb2 for Odin, rebuilt Odin and then it compiled ols fine.
Just thought I would mention it in case someone else runs into this problem before ols is updated. :)
I installed ols and vscode addon, added ols to path, but when i trying to type something it gives me this:
[Error - 4:30:56 PM] error in parse file for indexing /home/gohryt/Resources/Odin/Odin/core/builtin/builtin.odin
[Error - 4:30:56 PM] error in parse file for indexing /home/gohryt/Resources/Odin/Odin/core/intrinsics/intrinsics.odin
/home/gohryt/Resources/Odin/ols/src/server/analysis.odin(2373:31) Index -1 is out of bounds range 0:107
[Info - 4:31:03 PM] Connection to server got closed. Server will restart.
[Error - 4:31:03 PM] Request textDocument/completion failed.
Error: Connection got disposed.
at Object.dispose (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/connection.js:1044:27)
at Object.dispose (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-languageclient/lib/common/client.js:74:35)
at LanguageClient.handleConnectionClosed (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-languageclient/lib/common/client.js:2408:42)
at LanguageClient.handleConnectionClosed (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-languageclient/lib/node/main.js:155:15)
at closeHandler (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-languageclient/lib/common/client.js:2395:18)
at CallbackList.invoke (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/events.js:55:39)
at Emitter.fire (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/events.js:117:36)
at closeHandler (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/connection.js:256:26)
at CallbackList.invoke (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/events.js:55:39)
at Emitter.fire (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/events.js:117:36)
at StreamMessageWriter.fireClose (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/messageWriter.js:42:27)
at Socket. (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/messageWriter.js:75:42)
at Socket.emit (events.js:315:20)
at Pipe. (net.js:674:12)
[Error - 4:31:03 PM] error in parse file for indexing /home/gohryt/Resources/Odin/Odin/core/builtin/builtin.odin
[Error - 4:31:04 PM] error in parse file for indexing /home/gohryt/Resources/Odin/Odin/core/intrinsics/intrinsics.odin
/home/gohryt/Resources/Odin/ols/src/server/analysis.odin(2373:31) Index -1 is out of bounds range 0:107
[Info - 4:31:06 PM] Connection to server got closed. Server will restart.
[Error - 4:31:06 PM] Request textDocument/completion failed.
Error: Connection got disposed.
at Object.dispose (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/connection.js:1044:27)
at Object.dispose (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-languageclient/lib/common/client.js:74:35)
at LanguageClient.handleConnectionClosed (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-languageclient/lib/common/client.js:2408:42)
at LanguageClient.handleConnectionClosed (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-languageclient/lib/node/main.js:155:15)
at closeHandler (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-languageclient/lib/common/client.js:2395:18)
at CallbackList.invoke (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/events.js:55:39)
at Emitter.fire (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/events.js:117:36)
at closeHandler (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/connection.js:256:26)
at CallbackList.invoke (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/events.js:55:39)
at Emitter.fire (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/events.js:117:36)
at StreamMessageReader.fireClose (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/messageReader.js:40:27)
at Socket. (/home/gohryt/.vscode/extensions/danielgavin.ols-1.0.0/node_modules/vscode-jsonrpc/lib/common/messageReader.js:125:42)
at Socket.emit (events.js:327:22)
at Pipe. (net.js:674:12)
[Error - 4:31:06 PM] error in parse file for indexing /home/gohryt/Resources/Odin/Odin/core/builtin/builtin.odin
[Error - 4:31:06 PM] error in parse file for indexing /home/gohryt/Resources/Odin/Odin/core/intrinsics/intrinsics.odin
my ols.json wich i placed to project folder is:
{
"collections": [{ "name": "core", "path": "/home/gohryt/Resources/Odin/Odin/core" },
{ "name": "shared", "path": "/home/gohryt/Projects/Bomb" }],
"thread_pool_count": 4,
"enable_document_symbols": true,
"enable_semantic_tokens": false,
"enable_hover": true,
"enable_global_std": true,
"verbose": true
}
Hi
there seems to be a formatting issue in the following scenario:
err := foo(
var1 = nil,
var2 = nil,
var3 = nil,
var4 = nil,
var5 = nil,
var6 = nil,
var7 = nil,
)
formats to:
err := foo(
var1
= nil,
var2
= nil,
var3
= nil,
var4
= nil,
var5
= nil,
var6
= nil,
var7
= nil,
)
example: create_window(title="Hellope Title", monitor=nil, width=854, height=480, x=0, y=0)
This
package test
foreign import test {"system:c", "system:vulkan"}
foreign test {
my_proc :: proc(argument1: f32,argument2: f32,argument3: f32,argument4: f32,argument5: f32,argument6: f32) ---
}
Formats to
package test
foreign import test "system:c" "system:vulkan"
foreign test {
my_proc :: proc(
argument1: f32,
argument2: f32,
argument3: f32,
argument4: f32,
argument5: f32,
argument6: f32,
)
---
}
Which won't compile because {}
are removed from the list in foreign import
and ---
is placed on the line after )
The current semantic token has to resolve the entire file per key press, and this does not scale well with larger files. Implement the ability to only send the changes since last semantic request.
Add reference handling into the indexers.
Right now the when
conditions are hardcoded for handling ODIN_OS, but at some point it would be nice to support many other variables of the ODIN_* prefixes, and also not have it hardcoded, i.e. right now it only detects when ODIN_OS == "windows"
, but not when "windows" == ODIN_OS
Allow options to be set that completes all core without requiring it to be imported, and when the user completes a core symbol, it automatically adds an import to the top of the file.
Project with structure
ols.json
src/
main.odin
ols.json
{
"collections": [{ "name": "", "path": "." }],
"thread_pool_count": 4,
"enable_semantic_tokens": false,
"enable_document_symbols": true,
"enable_hover": true
}
main.odin
package main
typing "import" on line 3 of main.odin causes ols error:
C:/Odin/shared/ols/src/server/analysis.odin(2241:51) Invalid slice indices: 0:23:22
followed by crash.
#13 is likely related?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.