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

Account completion not work #32

Open
wrvsrx opened this issue Jul 5, 2021 · 18 comments
Open

Account completion not work #32

wrvsrx opened this issue Jul 5, 2021 · 18 comments
Labels
bug Something isn't working

Comments

@wrvsrx
Copy link
Contributor

wrvsrx commented Jul 5, 2021

Date completion works well, but account completion doesn't work.

Examples:
image

Here's my configuration:
image

@wrvsrx
Copy link
Contributor Author

wrvsrx commented Jul 5, 2021

Should I config treesitter additionally?

@polarmutex polarmutex added the bug Something isn't working label Jul 6, 2021
@xxgj
Copy link

xxgj commented Mar 4, 2023

+1

@polarmutex
Copy link
Owner

Tree sitter should not effect completion. I will try to reproduce and see what is going on. Thanks for reporting

@polarmutex
Copy link
Owner

I think I found the problem, It should be fixed in the develop branch in the repo

After I test the updated build over the next few days then I will move to main and create a release

@xxgj
Copy link

xxgj commented Mar 9, 2023

I think I found the problem, It should be fixed in the develop branch in the repo

After I test the updated build over the next few days then I will move to main and create a release

Really appreciate your work:)

@peterhoeg
Copy link

FWIW, the problem persists with v1.3.1. Regular accounts completion using beancount-mode in emacs works as expected but not when using this LS.

@polarmutex
Copy link
Owner

Do you have a minimal config for eMacs that I can try?

@peterhoeg
Copy link

I do.

  1. create a temporary directory and go there
  2. put this file there as emacs.org
  3. open emacs.org in emacs
  4. M-x org-babel-tangle
  5. Close emacs
  6. Then bash run.sh

Try going to the last line and put in Exp then hit tab. It will auto-complete the Expenses part but then no more. Without LSP, it works fine (you can remove the add-hook bit to not start LSP.

* runner
#+begin_src sh :tangle run.sh
#!/usr/bin/env bash

emacs --init-directory=. test.beancount
#+end_src

* early
#+begin_src elisp :tangle early-init.el
;;; early-init.el --- Minimal config
(setq package-enable-at-startup nil)
#+end_src

* init
#+begin_src elisp :tangle init.el
;;; init.el --- Minimal config

;; straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
#+end_src

* eglot

#+begin_src elisp :tangle init.el
(use-package eglot
  :defer t
  :config
  (add-to-list 'eglot-server-programs '(beancount-mode "beancount-language-server" "--stdio")))
#+end_src

* beancount

#+begin_src elisp :tangle init.el
(straight-use-package '(beancount-mode :type git :host github :repo "beancount/beancount-mode"))

(use-package beancount
  :mode ("\\.beancount\\'" . beancount-mode)
  :config
  (add-hook 'beancount-mode-hook #'eglot-ensure))
#+end_src

#+begin_src beancount :tangle test.beancount
2000-01-01 open Expenses:Foo
2000-01-01 open Expenses:Bar
2023-01-01 open Expenses:NotOpenForThisTnx
2028-01-01 open Expenses:NotOpenYet

2001-01-01 * "Foo" "Expense"

#+end_src

@peterhoeg
Copy link

peterhoeg commented Apr 28, 2023

I tried with 29.0.90 which has eglot (lsp support) built-in.

@polarmutex
Copy link
Owner

I will preface this with this, I am not a emacs user.

So I am running with the simple config and hit "Tab" and see "Expenses" fill in as you said. But If I hit "Tab" again I see a pop up with possible completions that seem what you want.

Could this be a configuration of eglot issue? I will play with it more and see If I see anything

@peterhoeg
Copy link

peterhoeg commented May 3, 2023 via email

@aclindsa
Copy link

I appear to be seeing this same (or at least a similar) problem using neovim today.

Here's an example log from the language server:

2023-07-12T11:10:01.137321Z DEBUG lsp_server::msg: < {"method":"textDocument\/completion","id":6,"jsonrpc":"2.0","params":{"position":{"line":95910,"character":28},"textDocument":{"uri":"file:\/\/\/path\/to\/my\/ledger.beancount"}}}
2023-07-12T11:10:01.137727Z  INFO beancount_language_server::server: handling event Lsp(Request(Request { id: RequestId(I32(6)), method: "textDocument/completion", params: Object {"position": Object {"character": Number(28), "line": Number(95910)}, "textDocument": Object {"uri": String("file:///path/to/my/ledger.beancount")}} }))
2023-07-12T11:10:01.138736Z DEBUG beancount_language_server::providers::completion: providers::completion
2023-07-12T11:10:01.138832Z DEBUG beancount_language_server::providers::completion: providers::completion - line 95910
2023-07-12T11:10:01.138850Z DEBUG beancount_language_server::providers::completion: providers::completion - char 28
2023-07-12T11:10:01.138866Z DEBUG beancount_language_server::providers::completion: providers::completion - start (95910, 27)
2023-07-12T11:10:01.138884Z DEBUG beancount_language_server::providers::completion: providers::completion - end (95910, 28)
2023-07-12T11:10:01.138926Z DEBUG beancount_language_server::providers::completion: providers::completion - is_char_triggered None
2023-07-12T11:10:01.138956Z DEBUG beancount_language_server::providers::completion: providers::completion - node Some({Node account (95910, 2) - (95910, 28)})
2023-07-12T11:10:01.139022Z DEBUG beancount_language_server::providers::completion: providers::completion - text Expenses:Entertainment:Mus
2023-07-12T11:10:01.139075Z DEBUG beancount_language_server::providers::completion: providers::completion - parent node Some({Node posting (95910, 0) - (95911, 0)})
2023-07-12T11:10:01.139104Z DEBUG beancount_language_server::providers::completion: providers::completion - parent node Some({Node posting_or_kv_list (95910, 0) - (95913, 0)})
2023-07-12T11:10:01.139149Z DEBUG beancount_language_server::providers::completion: providers::completion - prev sibling node None
2023-07-12T11:10:01.139199Z DEBUG beancount_language_server::providers::completion: providers::completion - prev named node None
2023-07-12T11:10:01.139243Z DEBUG beancount_language_server::providers::completion: providers::completion - handle node
2023-07-12T11:10:01.139793Z  INFO beancount_language_server::server: handling event Task(Response(Response { id: RequestId(I32(6)), result: Some(Null), error: None }))
2023-07-12T11:10:01.139839Z  INFO beancount_language_server::server: handled req#6 in 1.968957ms
2023-07-12T11:10:01.139890Z DEBUG lsp_server::msg: > {"jsonrpc":"2.0","id":6,"result":null}

The relevant transaction in my beancount file looks like:

2023-07-11 * "Fandango" "Fandango"
  Expenses:Entertainment:Mus
  Liabilities:Credit-Card  -30.64 USD

You'll see that I'm trying to auto-complete the "Expenses:Entertainment:Mus" account, which should complete to "Expenses:Entertainment:Music-Movies", which is a valid and existing account in my beancount file. But the server doesn't seem to return any completions for it.

@valpackett
Copy link

valpackett commented Feb 12, 2024

Using Helix and the latest version currently available on crates.io, account completions only appear for me when I backspace and type a letter that would result in fuzzy completions i.e. exists in some account with that prefix EXCEPT FOR the next letter 🤯

wtf rec

@polarmutex
Copy link
Owner

have not seen this with Neovim, I can play with Helix when I get a chance and see what is happening

@sohamshanbhag
Copy link

For me on neovim, v1.3.4 does not provide completion, while v1.3.3 does. If you can show point me to how to generate logs, I will do so.

@LumenYoung
Copy link

I can't get completion as well but all other work fine. Would be nice if we can sort this out

@Bergschrat1
Copy link

Hey,
First of all, thanks for the great work on this project!
I'm using Helix and for me it's also the account completion that isn't working.
What I have noticed is that the logs look different if it's the first posting or if it's the second:

First posting

2023-10-01 open Assets:Test USD
2023-10-01 open Expenses:Test USD
2023-10-01 txn  "Test Co" "Foo Bar"
    Assets:T
2024-10-27T19:40:14.942571Z DEBUG beancount_language_server::handlers::text_document: handlers::did_change
2024-10-27T19:40:14.942573Z DEBUG beancount_language_server::handlers::text_document: handlers::did_change - requesting file:///path/to/my/file/test.beancount
2024-10-27T19:40:14.942576Z DEBUG beancount_language_server::handlers::text_document: handlers::did_change - convert edits
2024-10-27T19:40:14.942584Z DEBUG beancount_language_server::handlers::text_document: handlers::did_change - apply edits - document
2024-10-27T19:40:14.942589Z DEBUG beancount_language_server::handlers::text_document: handlers::did_change - apply edits - tree
2024-10-27T19:40:14.942656Z DEBUG beancount_language_server::handlers::text_document: handlers::did_change - save tree
2024-10-27T19:40:14.942660Z DEBUG beancount_language_server::beancount_data: beancount_data:: get account nodes
2024-10-27T19:40:14.942662Z DEBUG beancount_language_server::beancount_data: beancount_data:: get account strings
2024-10-27T19:40:14.942664Z DEBUG beancount_language_server::beancount_data: beancount_data:: update accounts
2024-10-27T19:40:14.942674Z DEBUG beancount_language_server::beancount_data: beancount_data:: get narration nodes
2024-10-27T19:40:14.942676Z DEBUG beancount_language_server::beancount_data: beancount_data:: get account strings
2024-10-27T19:40:14.942682Z DEBUG beancount_language_server::beancount_data: beancount_data:: update narration
2024-10-27T19:40:14.942684Z DEBUG beancount_language_server::beancount_data: beancount_data:: update flagged entries
2024-10-27T19:40:14.942687Z DEBUG beancount_language_server::beancount_data: beancount_data:: get tags
2024-10-27T19:40:14.942817Z DEBUG beancount_language_server::beancount_data: beancount_data:: get tags
2024-10-27T19:40:14.942940Z DEBUG beancount_language_server::handlers::text_document: handlers::did_close - done

Second (or any following) posting

2023-10-01 open Assets:Test USD
2023-10-01 open Expenses:Test USD
2023-10-01 txn  "Test Co" "Foo Bar"
    Assets:Test   -5 USD
    Expe 
2024-10-27T19:45:49.461588Z DEBUG beancount_language_server::providers::completion: providers::completion
2024-10-27T19:45:49.461612Z DEBUG beancount_language_server::providers::completion: providers::completion - line 4 char 8
2024-10-27T19:45:49.461624Z DEBUG beancount_language_server::providers::completion: providers::completion - prev sibling node None
2024-10-27T19:45:49.461630Z DEBUG beancount_language_server::providers::completion: providers::completion - prev named sibling node None
2024-10-27T19:45:49.461634Z DEBUG beancount_language_server::providers::completion: providers::completion - parent node Some({Node ERROR (4, 0) - (4, 8)})
2024-10-27T19:45:49.461640Z DEBUG beancount_language_server::providers::completion: providers::completion - handle node Some({Node ERROR (4, 4) - (4, 8)})
2024-10-27T19:45:49.461650Z DEBUG beancount_language_server::providers::completion: providers::completion - text Expe
2024-10-27T19:45:49.461654Z DEBUG beancount_language_server::providers::completion: providers::completion - handle node
2024-10-27T19:45:49.461750Z  INFO beancount_language_server::server: handling event Task(Response(Response { id: RequestId(I32(17)), result: Some(Null), error: None }))
2024-10-27T19:45:49.461853Z  INFO beancount_language_server::server: handled req#17 in 357.173µs
2024-10-27T19:45:49.461927Z DEBUG lsp_server::msg: > {"jsonrpc":"2.0","id":17,"result":null}    

@polarmutex
Copy link
Owner

I have noticed some oddities with completions on my setup with Neovim.

its on my list to look at soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants