Skip to content

Latest commit

 

History

History
548 lines (469 loc) · 15.8 KB

snippets.org

File metadata and controls

548 lines (469 loc) · 15.8 KB

Finding all mono fonts

(prin1 (mapconcat'identity
      (sort (seq-filter (apply-partially #'s-matches?
                                         ".*mono.*"
                                         ) (font-family-list))
            #'string-lessp) "  \n  "))

smart?? garp collect

(defun k/garp_collect()
  (interactive)
  (while 1
    (progn
      (message "try gc")
      (sleep-for 0.1)
      (setq gc-cons-threshold-original 200)
      (garbage-collect)
      (setq gc-cons-threshold-original (* 1024 1024 20)))))

eshell

(defun eshell/clear ()
"Clear the eshell buffer. Type clear on eshell"
;; source: https://emacs.stackexchange.com/questions/12503/how-to-clear-the-eshell
(let ((inhibit-read-only t))
  (erase-buffer)
  (eshell-send-input)))

hide show

(defun kadir/hide-fold-defs ()
  "Folds the all functions in python"
  (interactive)
  (save-excursion
    (require 'hideshow)
    (goto-char (point-min))
    (hs-hide-level 2)))

pdf tools

(use-package pdf-tools
:load-path "/usr/share/emacs/site-lisp/pdf-tools/pdf-tools.el"
:demand t
:mode ("\\.pdf\\'" . pdf-view-mode)
:commands pdf-tools-install
:config
(pdf-tools-install) ;; initialise
(setq-default pdf-view-display-size 'fit-page)   ;; open pdfs scaled to fit page
;; automatically annotate highlights
(setq-default pdf-annot-activate-created-annotations t)
;; use normal isearch
(define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward))

buffer flip

  ;; (use-package buffer-flip
;;   :ensure t
;;   :bind  (("M-<SPC>" . buffer-flip)
;;           :map buffer-flip-map
;;           ( "M-<SPC>" .   buffer-flip-forward)
;;           ( "M-S-<SPC>" . buffer-flip-backward)
;;           ( "C-g" .     buffer-flip-abort)
;;           ( "M-g" .     buffer-flip-abort)
;;           )
;;   :config
;;   (setq buffer-flip-skip-patterns
;;         '("^\\*helm\\b"
;;           "^\\*swiper\\*$")))

which key

(use-package which-key
  :defer 3
  :config
  (which-key-mode)
  (which-key-setup-side-window-bottom)
  (setq which-key-idle-delay 0.4))

native

  (if (and (fboundp 'native-comp-available-p)
         (native-comp-available-p))
    (message "Native compilation is available")
  (message "Native complation is *NOTT* available"))

(if (functionp 'json-serialize)
    (message "Native JSON is available")
  (message "Native JSON is *NOTT* available"))

python

some packages

(use-package pony-mode)

smartjump

(use-package smart-jump
:defer 1
;; :init  (setq smart-jump-default-mode-list 'python-mode)
:config
(smart-jump-register :modes 'python-mode
                     :jump-fn 'xref-find-definitions
                     :pop-fn 'xref-pop-marker-stack
                     :refs-fn 'xref-find-references
                     :should-jump nil
                     :heuristic 'error
                     :async nil
                     :order 1)
;; (smart-jump-register :modes 'python-mode
;;                      :jump-fn 'kadir/jedi:goto-definition
;;                      :pop-fn 'jedi:goto-definition-pop-marker
;;                      :refs-fn 'xref-find-references
;;                      :should-jump t
;;                      :heuristic 'error
;;                      :async t
;;                      :order 2)
;; (smart-jump-register :modes 'python-mode
;;                      :jump-fn 'xref-find-definitions
;;                      :pop-fn 'xref-pop-marker-stack
;;                      :refs-fn 'xref-find-references
;;                      :should-jump t
;;                      :heuristic 'error
;;                      :async nil
;;                      :order 3)
;; (smart-jump-register :modes 'python-mode
;;                      :jump-fn 'dumb-jump-go
;;                      :pop-fn 'xref-pop-marker-stack
;;                      :should-jump t
;;                      :heuristic 'point
;;                      :async nil
;;                      :order 4)
)

jedi

  (use-package company-jedi)
(use-package jedi-core
  :init
  (setq jedi:goto-definition-marker-ring-length 50)
  (setq jedi:get-in-function-call-timeout 0)
  (setq company-async-timeout 9.001)
  :config


  (defun kadir/jedi:goto-definition()
    (interactive)
    (ring-insert jedi:goto-definition--marker-ring (point-marker))
    (jedi:goto-definition))

  (defun kadir/python-curson-on-import-p()
    (save-excursion (mwim-beginning-of-code-or-line) (looking-at ".*import.*")))

  (defun jedi:goto-definition--callback (reply other-window)
    (if (not reply)
        (message "Definition not found.")
      (setq jedi:goto-definition--cache reply)
      (jedi:goto-definition--nth other-window t)

      ;; kadir adds
      (when (kadir/python-curson-on-import-p)
        (jedi:goto-definition))))

  (defun jedi:goto-definition-push-marker ()
    "Push point onto goto-definition marker ring."
    (when (not (kadir/python-curson-on-import-p))
      (ring-insert jedi:goto-definition--marker-ring (point-marker))))


  )


(defun company-jedi-candidates (callback)
  "Return company candidates with CALLBACK."
  (deferred:nextc
    (jedi:call-deferred 'complete)
    (lambda (reply)
      (message "%s" reply)
      (let ((candidates (mapcar 'company-jedi-collect-candidates reply)))
        (funcall callback candidates)))))

Tabnine

(use-package company-tabnine
  :defer 20
  :config
  (require 'company-tabnine)

  (defun kadir/company-tabnine-disable()
    (interactive)
    (setq company-backends (remove 'company-tabnine company-backends)))

  (defun kadir/company-tabnine-enable()
    (interactive)
    (add-to-list 'company-backends 'company-tabnine))

  (setq company-tabnine--disable-next-transform nil)
  (defun my-company--transform-candidates (func &rest args)
    (if (not company-tabnine--disable-next-transform)
        (apply func args)
      (setq company-tabnine--disable-next-transform nil)
      (car args)))

  (defun my-company-tabnine (func &rest args)
    (when (eq (car args) 'candidates)
      (setq company-tabnine--disable-next-transform t))
    (apply func args))

  (advice-add #'company--transform-candidates :around #'my-company--transform-candidates)
  (advice-add #'company-tabnine :around #'my-company-tabnine))
(require 'company-tabnine)
(setq company-backends '(company-tabnine))

wucuo

(use-package wucuo
  :init
  (setq ispell-program-name "aspell")
  (setq ispell-extra-args '("--sug-mode=ultra" "--Lang=en_US" "--run-together" "--run-together-limit=16" "--camel-case"))

  (setq wucuo-debug t)
  (setq wucuo-flyspell-start-mode "fast")
  (add-hook 'prog-mode-hook #'wucuo-start)
  (add-hook 'text-mode-hook #'wucuo-start)
  (setq wucuo-personal-font-faces-to-check '(font-lock-type-face))

  (setq kadir/wucuo-safe-words
        '("kadir"
          "alist"
          "serializer"
          ))

  (defun kadir/wucuo-not-check-function (word)
    (if (-contains? kadir/wucuo-safe-words word)
        (progn
          (message "in: %s" word)
          nil)
      t)
    )

  (setq wucuo-extra-predicate #'kadir/wucuo-not-check-function)

  (defun kadir/open-fly-a-wucuo-spell-file()
    (interactive)
    ;; (wucuo-create-aspell-personal-dictionary)
    (find-file (file-truename (format "~/.aspell.%s.pws" wucuo-aspell-language-to-use))))

  (setq wucuo-update-interval 0.5))

imenu

(use-package imenu-list
:init
(setq imenu-list-position 'left)
(setq imenu-list-auto-resize nil)
(setq imenu-list-focus-after-activation t)

(defun kadir/imenu-change-function(arg)
  (run-with-idle-timer
   0.5 nil
   (lambda ()
     (imenu-list-update-safe))))

(defun kadir/imenu-list()
  (interactive)
  (add-to-list 'window-selection-change-functions 'kadir/imenu-change-function)
  (imenu-list)
  (kadir/buffer-to-side-left)
  (when (derived-mode-p 'imenu-list-major-mode)
    (delete-window))))

avy

(use-package avy
  :bind (;; ("C-q" . avy-goto-char)
         ("C-q" . avy-goto-line)
         ;; ("M-g f" . avy-goto-line)
         ;; ("M-g w" . avy-goto-word-1)
         ;; ("M-g e" . avy-goto-word-0)
         )
  :hook (after-init . avy-setup-default)
  :config
  (setq avy-all-windows t
        avy-background t
        avy-style 'pre
        avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?q  ?w ?e ;;?u ?n ?m ?v ?ı ?o ?x ?ü ?i)))

(defun avy-goto-word-2 (char1 char2 &optional arg beg end symbol)
    ;; inpired: https://github.com/abo-abo/avy/issues/198
    (interactive (list (read-char "char 1: " t)
                       (read-char "char 2: " t)
                       current-prefix-arg))
    (avy-with avy-goto-word-2
      (let* ((str1 (string char1))
             (str2 (string char2))
             (regex1 (cond ((string= str1 ".")
                            "\\.")
                           ((and avy-word-punc-regexp
                                 (string-match avy-word-punc-regexp str1))
                            (regexp-quote str1))
                           ((<= char1 26)
                            str1)
                           (t
                            (concat
                             (if symbol "\\_<" "\\b")
                             str1))))
             (regex2 (cond ((string= str2 ".")
                            "\\.")
                           ((and avy-word-punc-regexp
                                 (string-match avy-word-punc-regexp str2))
                            (regexp-quote str2))
                           ((<= char2 26)
                            str2)
                           (t
                            str2)))
             (regex (concat regex1 regex2)))

        (avy-jump regex
                  :window-flip arg
                  :beg beg
                  :end end)

        )))

Dap mode

(use-package dap-mode
  :init

  (setq dap-auto-configure-features '(sessions locals controls tooltip))
  (dap-mode 1)

  ;; The modes below are optional
  (dap-ui-mode 1)
  ;; enables mouse hover support
  (dap-tooltip-mode 1)
  ;; use tooltips for mouse hover
  ;; if it is not enabled `dap-mode' will use the minibuffer.
  (tooltip-mode 1)
  ;; displays floating panel with debug buttons
  ;; requies emacs 26+
  (dap-ui-controls-mode 1)

  ;; python -m debugpy --listen 0:5678 --wait-for-client manage.py runserver 0:8000

  (dap-register-debug-provider
   "python"
   (lambda (conf)
     (plist-put conf :debugPort 5678)
     (plist-put conf :host "localhost")
     (plist-put conf :hostName "localhost")
     (plist-put conf :debugServer 5678)
     conf))

  (dap-register-debug-template
   "conf"
   (list :type "python"
         :request "attach"
         :port 5678
         :name "test"
         :pathMappings
         (list (ht
                ("localRoot" "/home/kadir/bigescom-pro/")
                ("remoteRoot" "/app/")
                ))
         :sourceMaps t))

  (use-package hydra
    :init
    (require 'hydra))

  (add-hook 'dap-stopped-hook
            (lambda (arg) (call-interactively #'dap-hydra))))

zoom

(use-package zoom
  :init
  (zoom-mode)
  (setq zoom-size '(85 . 22)))

nano modeline

(use-package nano-modeline
:straight (nano-modeline :type git :host github :repo "rougier/nano-modeline")
(require 'kadir-modeline)

(setq nano-modeline-position 'bottom)
(nano-modeline-mode 1)
(set-face-attribute 'nano-modeline-active-status-** nil :background "red")
(set-face-attribute 'nano-modeline-inactive-status-** nil :background "red")

(defun nano-modeline-default-mode ()

  (when (buffer-file-name (current-buffer)))

  (let* ((is-file (buffer-file-name (current-buffer)))
         (relative-path (when is-file (s-chop-prefix (projectile-project-root) (buffer-file-name (current-buffer)) )))
         (file-splitted (when is-file (s-split "/" relative-path)))
         (file-name (if is-file
                        (concat (nth (- (length file-splitted) 1) file-splitted))
                      (format-mode-line "%b")))
         (folder-name (when is-file (s-chop-suffix file-name relative-path)))
         (mode-name   (nano-modeline-mode-name))
         (branch      (nano-modeline-vc-branch))
         (position    (format-mode-line "%l:%c")))


    (nano-modeline-compose (nano-modeline-status)

                           file-name

                           (concat (when (and (not (s-equals? folder-name "")) folder-name)
                                     (concat " (" folder-name ")  "))
                                   "(" mode-name ")"
                                   )
                           (concat branch "  -  " position)))))

doom mode line

(use-package doom-modeline
:defer nil
:config
(setq doom-modeline-bar-width         1
      doom-modeline-height            1
      doom-modeline-buffer-encoding   nil
      ;; doom-modeline-buffer-modification-icon t
      doom-modeline-vcs-max-length    20
      doom-modeline-icon              t
      ;; relative-to-project
      doom-modeline-buffer-file-name-style 'relative-from-project)

(set-face-attribute 'mode-line nil :height kadir/default-font-size)
(set-face-attribute 'mode-line-inactive nil :height kadir/default-font-size)
(setq doom-modeline-lsp nil)
(setq doom-modeline-icon t)
(setq doom-modeline-minor-modes t)
(setq doom-modeline-major-mode-icon nil)
(setq doom-modeline-buffer-encoding nil)
(setq doom-modeline-env-version nil)
(doom-modeline-mode 1))

which key

(use-package which-key
:defer 3
:config
(which-key-mode)
(which-key-setup-side-window-bottom)
(setq which-key-idle-delay 2.0)
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration))

magit delta

(use-package magit-delta
  :init
  (add-hook 'magit-mode-hook (lambda () (magit-delta-mode +1))))

centaur tabs

(use-package centaur-tabs
  :defer 10
  :bind
  ("C-x n" . centaur-tabs-backward)
  ("C-x C-n" . centaur-tabs-backward)
  :config
  (centaur-tabs-mode -1) ;; disabled (yes)
  (setq centaur-tabs-set-modified-marker t
        centaur-tabs-plain-icons t
        centaur-tabs-style "bar"
        centaur-tabs-set-close-button nil
        centaur-tabs-height 20
        centaur-tabs-label-fixed-length 15
        centaur-tabs-cycle-scope 'tabs)

  (centaur-tabs-group-by-projectile-project)

  ;; (setq centaur-tabs-buffer-groups-function)
  (progn
    (defun kadir/centuar-group-last-five-buffer()
      (list (projectile-project-name)))
    (setq centaur-tabs-buffer-groups-function 'kadir/centuar-group-last-five-buffer)

    (defun kadir/centaur-tabs-hide-tab (x)
      (not (buffer-file-name x)))
    (setq centaur-tabs-hide-tab-function 'kadir/centaur-tabs-hide-tab)))

explain pause mode

(use-package explain-pause-mode
  :defer 1
  :straight (explain-pause-mode :type git :host github :repo "lastquestion/explain-pause-mode")
  :init
  (explain-pause-mode)
  )

tilde fringe

(use-package vi-tilde-fringe
  :defer 1.2
  :config
  (setq vi-tilde-fringe-bitmap-array
        [#b00000000
         #b00000000
         #b00000000
         #b00101000
         #b00010100
         #b00000000
         #b00000000
         #b00000000])
  (global-vi-tilde-fringe-mode 0)
  (global-vi-tilde-fringe-mode 1))