nimlsp icon indicating copy to clipboard operation
nimlsp copied to clipboard

Problem using strformat/fmt (neovim)

Open DestyNova opened this issue 3 years ago • 4 comments

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

DestyNova avatar Dec 04 '22 05:12 DestyNova

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.

PMunch avatar Dec 28 '22 13:12 PMunch

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)

DestyNova avatar Jan 19 '23 17:01 DestyNova

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.

PMunch avatar Jan 24 '23 08:01 PMunch

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.

DestyNova avatar Jan 24 '23 17:01 DestyNova