joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.25k stars 201 forks source link

error "(wrong-type-argument number-or-marker-p nil)" when using imenu for golang source files. #547

Open brianjcj opened 4 years ago

brianjcj commented 4 years ago

error "(wrong-type-argument number-or-marker-p nil)" when using imenu for golang source files:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
min(2305843009213693951 nil)
(forward-line (min most-positive-fixnum (plist-get pos-plist :line)))
(save-excursion (goto-char (point-min)) (forward-line (min most-positive-fixnum (plist-get pos-plist :line))) (unless (eobp) (let ((tab-width 1) (col (plist-get pos-plist :character))) (unless (wholenump col) $ eglot--lsp-position-to-point(nil)

f(compiled-function () #<bytecode 0x3bc5845>)()

eglot--call-with-interface((SymbolInformation (:name :kind :location) (:deprecated :containerName)) (:name "JOIN_PROPS_MULTIJOIN_BY_INSTANCEID" :detail "untyped string" :kind 14 :range (:start (:line 52 :chara$

f(compiled-function (jsonrpc-lambda-elem45) #<bytecode 0x2d2232d>)((:name "JOIN_PROPS_MULTIJOIN_BY_INSTANCEID" :detail "untyped string" :kind 14 :range (:start (:line 52 :character 0) :end (:line 54 :characte$

mapcar(#f(compiled-function (jsonrpc-lambda-elem45) #<bytecode 0x2d2232d>) [(:name "JOIN_PROPS_MULTIJOIN_BY_IN..." :detail "untyped string" :kind 14 :range (:start ... :end ...) :selectionRange (:start ... :en$ eglot-imenu()
apply(eglot-imenu nil)

f(advice-wrapper :before-until lsp--imenu-create-index eglot-imenu)()

imenu--make-index-alist(t)
counsel--imenu-candidates()
counsel-imenu()

joaotavora commented 4 years ago

You're not using imenu, you're using counsel-imenu. I would counsel it (haha silly joke) to understand the full imenu item specification, which includes functions as menu item targets. I also see some "advice" there, which is also suspicious.

I'm not 100% sure this is the problem, but it's pretty similar to other imenu-related issues that have popped up recently. To make sure, please try with M-x imenu and tell me if you experience a similar problem. If you do, I will reopen.

brianjcj commented 4 years ago

M-x imenu is ok. but the content is not right. and it does not invoke eglot-imenu function.

brianjcj commented 4 years ago

gopls resut json format is very different than those from clangd:

client-request (id:2) Wed Sep 30 21:02:31 2020:
(:jsonrpc "2.0" :id 2 :method "textDocument/documentSymbol" :params
(:textDocument
(:uri "file:///home/brianjcj/my-projects/server/channel/chatroom/auther/handler/auther.go")))

server-reply (id:2) Wed Sep 30 21:02:31 2020:
(:jsonrpc "2.0" :result
[(:name "JOIN_PROPS_MULTIJOIN_BY_INSTANCEID" :detail "untyped string" :kind 14 :range
(:start
(:line 52 :character 0)
:end
(:line 54 :character 1))
:selectionRange
(:start
(:line 53 :character 1)
:end
(:line 53 :character 35)))
(:name "ROBOT_INSTANCEID" :detail "untyped int" :kind 14 :range
(:start
(:line 56 :character 0)
:end
(:line 58 :character 1))
:selectionRange
(:start
(:line 57 :character 1)
:end
(:line 57 :character 17)))
(:name "Auther" :detail "struct{...}" :children
[(:name "XMLConfig" :detail "config.XMLConfig" :kind 8 :range
(:start
(:line 62 :character 1)
:end
(:line 62 :character 31))
:selectionRange
(:start
(:line 62 :character 1)
:end
(:line 62 :character 10)))
(:name "ApolloConfig" :detail "
config.ApolloConfig" :kind 8 :range

brianjcj commented 4 years ago

here is return by clangd for c++ source files. and eglot can handle it.

client-request (id:323) Wed Sep 30 20:54:01 2020:
(:jsonrpc "2.0" :id 323 :method "textDocument/documentSymbol" :params
(:textDocument
(:uri "file:///home/brianjcj/my-projects/server/channel/chatroom/chatroom_online/server/online_core/ChannelManager.cpp")))

server-reply (id:323) Wed Sep 30 20:54:01 2020:
(:id 323 :jsonrpc "2.0" :result
[(:containerName "" :kind 13 :location
(:range
(:end
(:character 28 :line 17)
:start
(:character 16 :line 17))
:uri "file:///home/brianjcj/my-projects/server/channel/chatroom/chatroom_online/server/online_core/ChannelManager.cpp")
:name "using namespace onlineCommon")
(:containerName "" :kind 5 :location
(:range
(:end
(:character 0 :line 29)
:start
(:character 0 :line 19))
:uri "file:///home/brianjcj/my-projects/server/channel/chatroom/chatroom_online/server/online_core/ChannelManager.cpp")
:name "ProducerCb")
(:containerName "" :kind 6 :location
(:range
(:end
(:character 2 :line 28)
:start
(:character 2 :line 21))
:uri "file:///home/brianjcj/my-projects/server/channel/chatroom/chatroom_online/server/online_core/ChannelManager.cpp")
:name "onMessageSent")

brianjcj commented 4 years ago

(defun eglot-imenu () "EGLOT's `imenu-create-index-function'." (let ((entries (and (eglot--server-capable :documentSymbolProvider) (mapcar (eglot--lambda ((SymbolInformation) name kind location containerName) ;; <====== containerName

brianjcj commented 4 years ago

gopls resut json format is very different than those from clangd:

client-request (id:2) Wed Sep 30 21:02:31 2020: (:jsonrpc "2.0" :id 2 :method "textDocument/documentSymbol" :params (:textDocument (:uri "file:///home/brianjcj/my-projects/server/channel/chatroom/auther/handler/auther.go")))

server-reply (id:2) Wed Sep 30 21:02:31 2020: (:jsonrpc "2.0" :result [(:name "JOIN_PROPS_MULTIJOIN_BY_INSTANCEID" :detail "untyped string" :kind 14 :range (:start (:line 52 :character 0) :end (:line 54 :character 1)) :selectionRange (:start (:line 53 :character 1) :end (:line 53 :character 35))) (:name "ROBOT_INSTANCEID" :detail "untyped int" :kind 14 :range (:start (:line 56 :character 0) :end (:line 58 :character 1)) :selectionRange (:start (:line 57 :character 1) :end (:line 57 :character 17))) (:name "Auther" :detail "struct{...}" :children [(:name "XMLConfig" :detail "config.XMLConfig" :kind 8 :range (:start (:line 62 :character 1) :end (:line 62 :character 31)) :selectionRange (:start (:line 62 :character 1) :end (:line 62 :character 10))) (:name "ApolloConfig" :detail "config.ApolloConfig" :kind 8 :range

it have children nodes also....

brianjcj commented 4 years ago

i try lsp-mode. it works. here is the result:

167 candidates: GetServiceFunctionName GetServiceServiceName NewAuther JOIN_PROPS_MULTIJOIN_BY_INSTANCEID ROBOT_INSTANCEID Auther: AddOrUpdateChatRoomInfo Auther: AddOrUpdateUserInfo Auther: CreateChatRoom Auther: CreateChatRoomServer Auther: CreateRoomServerHttp Auther: DeleteUserInfo Auther: DisableRoomServer Auther: DisableUserText Auther: DisableUserTextServer Auther: DismissChatRoom Auther: DismissChatRoomServer

brianjcj commented 4 years ago

ok. it will be fixed by this issue: https://github.com/joaotavora/eglot/pull/303

joaotavora commented 4 years ago

ok. it will be fixed by this issue: #303

Hmm, that is odd. That has been merged for a while now.

It's very odd that M-x imenu doesn't work. Also, I've noticed that the "advice" that I called "suspicious" before, is being added by me. So please disregard that :-)