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

Problem using strformat/fmt (neovim) #149

Open
DestyNova opened this issue Dec 4, 2022 · 4 comments
Open

Problem using strformat/fmt (neovim) #149

DestyNova opened this issue Dec 4, 2022 · 4 comments

Comments

@DestyNova
Copy link

DestyNova commented Dec 4, 2022

Hi, I'm getting output like this when I use fmt strings with interpolation:

import strformat
let x = 1 + 1
echo(fmt"1 + 1 = {x}")

This compiles fine, but shows the error expression expected, but found ')' in neovim. I'm not sure exactly what's responsible for this message but it happens a lot.

Here's how it looks when I'm editing:

Screenshot_2022-12-04_05-49_nimlsp

@PMunch
Copy link
Owner

PMunch commented Dec 28, 2022

This is likely a nimsuggest error, could you try with nimsuggest and see if you can reproduce it there? If you can then report this to the nimsuggest bug tracker instead.

@DestyNova
Copy link
Author

DestyNova commented Jan 19, 2023

Sorry to come back to this so late. How do I run this through nimsuggest? It drops me into an interactive prompt with options. I tried this file with nimsuggest, calling chk, and got different errors that may be due to nimsuggest expecting a project file.
Screenshot_2023-01-19_17-55

nim check on the other hand prints no errors and reports success.

Could this all be down to working on standalone Nim files that aren't part of a project?
(edit: it doesn't seem to matter whether the file is in a Nimble project or not)

@PMunch
Copy link
Owner

PMunch commented Jan 24, 2023

If you run nimlsp_debug instead of the normal nimlsp binary you will get a log which contains things like "Running the equivalent of def bugrep.nim:10:15" for example.

@DestyNova
Copy link
Author

DestyNova commented Jan 24, 2023

I'm not sure if this is the right logfile, but I added this config:

let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('~/code/tmp/nvim-lsp.log')

Then I made an empty directory containing a file wat.nim with this contents:

for i in 1..3:
  echo "Hello"

Saving this file in neovim and then exiting produces this output in the log:

Tue 24 Jan 2023 17:31:56:["s:on_text_document_did_open()", 1, "nim", "/home/omf/code/nimlsp_test", "file:///home/omf/code/nimlsp_test/wat.nim"]
Tue 24 Jan 2023 17:31:57:["s:on_text_document_did_save()", 1]
Tue 24 Jan 2023 17:32:06:["s:on_text_document_did_close()", 1]

Then I initialised a new git repo and added the file with git init && git add wat.nim. Opening the file again with neovim and writing it back with :w now produces this output:

>> for i in 1..3: # E: expression 'n' has no type (or is ambiguous)                                                                                                                                                                      
>>   echo "Hello" # E: invalid indentation   

Log output was the same. Somehow the error messages are affected by git. Not sure if it's another plugin (e.g. vim-fugitive) affecting it -- will try to debug more.

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

No branches or pull requests

2 participants