Skip to content

Latest commit

 

History

History
247 lines (216 loc) · 12 KB

TODOs.org

File metadata and controls

247 lines (216 loc) · 12 KB

lsp next prev occurence

We may implement this method by using either textDocument/documentHighlight which are scoped to the current buffer or by textDocument/references (which is not scoped to the current buffer). If you want to give it a try you may take a look at lsp–make-document-highlight-callback which is handling the rendering of the highlights. It will be good if we reuse the data for two subsequent calls to next occurrence if there are no changes.

call lsp highlight and log out result

(:jsonrpc “2.0” :method “textDocument/documentHighlight” :params (:textDocument (:uri “file:///home/gvuong/git/ivt6/projects/web/src/webserver/src/routes/api/hvr-cameras.js”) :position (:line 75 :character 10)) :id 23) highlight: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“kind” 2 “range” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“start” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 75 “character” 10)) “end” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 75 “character” 18)))))) range: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“start” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 75 “character” 10)) “end” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 75 “character” 18)))) kind: 2 start: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 75 “character” 10)) end: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 75 “character” 18)) highlight: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“kind” 2 “range” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“start” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 76 “character” 16)) “end” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 76 “character” 24)))))) range: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“start” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 76 “character” 16)) “end” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 76 “character” 24)))) kind: 2 start: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 76 “character” 16)) end: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 76 “character” 24)) highlight: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“kind” 2 “range” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“start” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 78 “character” 51)) “end” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 78 “character” 59)))))) range: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“start” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 78 “character” 51)) “end” #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 78 “character” 59)))) kind: 2 start: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 78 “character” 51)) end: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 78 “character” 59))

convert `start` to point with lsp–position-to-point

(:jsonrpc “2.0” :method “textDocument/documentHighlight” :params (:textDocument (:uri “file:///home/gvuong/git/ivt6/projects/web/src/webserver/src/routes/api/hvr-cameras.js”) :position (:line 75 :character 10)) :id 24) start: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 75 “character” 10)) end: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 75 “character” 18)) point: 2182 start: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 76 “character” 16)) end: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 76 “character” 24)) point: 2242 start: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 78 “character” 51)) end: #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (“line” 78 “character” 59)) point: 2304

once you have the list of point you need to have

  • current point
  • compare current point to find next and prev points

let check

helm evil mark

reuse part of evil-show-marks to generate helm source use evil-goto-mark to go to buffer

helm lsp

symbols with context

ivy from doom

[x] full length highlight [ ] better-jump [ ] kill ring [ ] ivy-rich Yevgnen/ivy-rich#87 doomemacs/doomemacs#1317 syl20bnr/spacemacs#10101 Yevgnen/ivy-rich#57 [ ] c-r bound to minibuffer history in spacemacs

;; A Doom convention where C-s on popups and interactive searches will invoke
;; ivy/helm for their superior filtering.
(when-let (command (cond ((featurep! :completion ivy)
                          #'counsel-minibuffer-history)
                         ((featurep! :completion helm)
                          #'helm-minibuffer-history)))
  (define-key!
    :keymaps (append +default-minibuffer-maps
                     (when (featurep! :editor evil +everywhere)
                       '(evil-ex-completion-map)))
    "C-s" command))

[ ]

lsp-sov

a function to refresh the symbol list

create a hash table then go through the buffer for each overlay get the symbol info and face value

put it in the hash table { face: symbol }

then maphash the table

grep-buffer-maker

can’t handle non projet files must avoid non file buffers should a mode to turn on the key binding to the feature?

bug with extra new line

this will cause wgrep to take the last line as grep footer

(defun wgrep-prepare-header&footer () (let (beg end) ;; Set read-only grep result header (goto-char (point-min)) (setq beg (point-min)) ;; See `compilation-start’ (forward-line 4) (setq end (point)) (put-text-property beg end ‘read-only t) (put-text-property beg end ‘wgrep-header t) ;; Set read-only grep result footer (goto-char (point-max)) (forward-line -1) (when (re-search-backward “^$” end t) (setq beg (point)) (setq end (point-max)) (when beg (put-text-property beg end ‘read-only t) (put-text-property beg end ‘wgrep-footer t)))))

don’t create new line

but new line is a hint of new block

add extra two new lines

add a default footer

chat gpt org mode design

question in a node, and body answer is body of a child node

get node lists

question 1: hello

I’m asking this

answer

hi im answering

question 1: hello

I’m asking this

answer

hi im answering

api to use

org data

(org-data nil
          (headline
           (:raw-value "question 1: hello" :begin 1 :end 64 :pre-blank 0 :contents-begin 21 :contents-end 63 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 1 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 1 :title
                       (#("question 1: hello" 0 17
                          (:parent #1)))
                       :parent #0)
           (section
            (:begin 21 :end 37 :contents-begin 21 :contents-end 37 :post-blank 0 :post-affiliated 21 :parent #1)
            (paragraph
             (:begin 21 :end 37 :contents-begin 21 :contents-end 37 :post-blank 0 :post-affiliated 21 :parent #2)
             #("I'm asking this
" 0 16
(:parent #3))))
           (headline
            (:raw-value "answer" :begin 37 :end 63 :pre-blank 0 :contents-begin 47 :contents-end 63 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 37 :title
                        (#("answer" 0 6
                           (:parent #2)))
                        :parent #1)
            (section
             (:begin 47 :end 64 :contents-begin 47 :contents-end 63 :post-blank 1 :post-affiliated 47 :parent #2)
             (paragraph
              (:begin 47 :end 63 :contents-begin 47 :contents-end 63 :post-blank 0 :post-affiliated 47 :parent #3)
              #("hi im answering
" 0 16
(:parent #4))))))
          (headline
           (:raw-value "question 1: hello" :begin 64 :end 182 :pre-blank 0 :contents-begin 84 :contents-end 182 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 64 :title
                       (#("question 1: hello" 0 17
                          (:parent #1)))
                       :parent #0)
           (section
            (:begin 84 :end 111 :contents-begin 84 :contents-end 111 :post-blank 0 :post-affiliated 84 :parent #1)
            (paragraph
             (:begin 84 :end 101 :contents-begin 84 :contents-end 100 :post-blank 1 :post-affiliated 84 :parent #2)
             #("I'm asking this
" 0 16
(:parent #3)))
            (paragraph
             (:begin 101 :end 111 :contents-begin 101 :contents-end 111 :post-blank 0 :post-affiliated 101 :parent #2)
             #("blah blah
" 0 10
(:parent #3))))
           (headline
            (:raw-value "answer" :begin 111 :end 182 :pre-blank 0 :contents-begin 121 :contents-end 182 :level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 111 :title
                        (#("answer" 0 6
                           (:parent #2)))
                        :parent #1)
            (section
             (:begin 121 :end 182 :contents-begin 121 :contents-end 182 :post-blank 0 :post-affiliated 121 :parent #2)
             (paragraph
              (:begin 121 :end 138 :contents-begin 121 :contents-end 137 :post-blank 1 :post-affiliated 121 :parent #3)
              #("hi im answering
" 0 16
(:parent #4)))
             (src-block
              (:language "python" :switches nil :parameters nil :begin 138 :end 182 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value "print(\"hello\")
" :post-blank 0 :post-affiliated 138 :parent #3))))))

chat org

first level header and its section is question, the member subheader is the answer

chat gpt api

https://platform.openai.com/docs/api-reference/chat/create?lang=python

they only support python, nodejs is community supported. only python can stream response

https://platform.openai.com/docs/guides/chat/introduction

import openai

openai.ChatCompletion.create( model=”gpt-3.5-turbo”, messages=[ {“role”: “system”, “content”: “You are a helpful assistant.”}, {“role”: “user”, “content”: “Who won the world series in 2020?”}, {“role”: “assistant”, “content”: “The Los Angeles Dodgers won the World Series in 2020.”}, {“role”: “user”, “content”: “Where was it played?”} ] )

ducking

input a list of buffers a list of 10 letters a suffix string a max length

output

a string of from the list of buffers each prefixed with a letter concat with teh suffix string the number of the buffers in the list

the length of the string cannot be greater than max length. If is is then the buffer must be cut off and added … then concat with suffix string

also

loop on buffers state total length state current length state letter index create new buffer name append with the letter calc current length of the new buffer if length + current lenght < max do it update the current length continue else length is greater can buffer is ok to add …