|
104 | 104 | :group 'lsp-ocaml-server
|
105 | 105 | :type 'boolean)
|
106 | 106 |
|
107 |
| -(cl-defmethod lsp-clients-extract-signature-on-hover (contents (_server-id (eql ocaml-lsp-server)) &optional storable) |
108 |
| - "Extract a representative line from OCaml's CONTENTS, to show in the echo area. |
109 |
| -This function splits the content between the signature |
110 |
| -and the documentation to display the signature |
111 |
| -and truncate it if it's too wide. |
112 |
| -The STORABLE argument is used if you want to use this |
113 |
| -function to get the type and, for example, kill and yank it. |
114 |
| -
|
115 |
| -An example of function using STORABLE is: |
116 |
| -
|
117 |
| - (defun mdrp/lsp-get-type-and-kill () |
118 |
| - (interactive) |
119 |
| - (let ((contents (-some->> (lsp--text-document-position-params) |
120 |
| - (lsp--make-request \"textDocument/hover\") |
121 |
| - (lsp--send-request) |
122 |
| - (lsp:hover-contents)))) |
123 |
| - (let ((contents (and contents |
124 |
| - (lsp--render-on-hover-content |
125 |
| - contents |
126 |
| - t)))) |
127 |
| - (let ((contents |
128 |
| - (pcase (lsp-workspaces) |
129 |
| - (`(,workspace) |
130 |
| - (lsp-clients-extract-signature-on-hover |
131 |
| - contents |
132 |
| - (lsp--workspace-server-id workspace) |
133 |
| - t)) |
134 |
| - (lsp-clients-extract-signature-on-hover |
135 |
| - contents |
136 |
| - nil) |
137 |
| - ))) |
138 |
| - (message \"Copied %s to kill-ring\" contents) |
139 |
| - (kill-new contents)))))" |
140 |
| - (let ((type (s-trim (lsp--render-element (lsp-make-marked-string |
141 |
| - :language "ocaml" |
142 |
| - :value (car (s-split "---" (lsp--render-element contents)))))))) |
143 |
| - (if (equal nil storable) |
144 |
| - (if (eq lsp-cut-signature 'cut) |
145 |
| - (car (s-lines type)) |
146 |
| - ;; else lsp-cut-signature is 'space |
147 |
| - (let ((ntype (s-replace "\n" " " type))) |
148 |
| - (if (>= (length ntype) (frame-width)) |
149 |
| - (concat (substring ntype 0 (- (frame-width) 4)) "...") |
150 |
| - ntype))) |
151 |
| - type))) |
152 |
| - |
153 | 107 | ;;; -------------------
|
154 | 108 | ;;; OCaml-lsp faces
|
155 | 109 | ;;; -------------------
|
|
0 commit comments