dotfiles/.emacs.d/init.el

296 lines
8.8 KiB
EmacsLisp
Raw Normal View History

;;;;;;;;;;;;
;; PAKETI ;;
;;;;;;;;;;;;
;; Set up package.el to work with MELPA
(require 'package)
;; Sekvence n'shiat
(require 'seq)
;; Loudamo melpa paketice
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
;; Kaj vse naj bo namesceno?
(setq paketi '(;; Evil mode
2021-04-25 00:43:50 +02:00
evil
evil-collection
evil-org
;; Global undo tree
2021-04-25 00:43:50 +02:00
undo-tree
;; Gruvbox tema
gruvbox-theme
;; Hemisu tema
hemisu-theme
2021-04-25 00:43:50 +02:00
;; Doom themes
doom-themes
;; Oblikovanje teksta
editorconfig
;; PHProgamiranje
php-mode
fennel-mode
;; Projekti
projectile
;; Completion
company
;; Completion2
ivy
2021-04-25 00:43:50 +02:00
;; Iskanje
swiper
;; Izboljsani default ukazi bolj prijazni
counsel
;; Iskanje po fajlih
2021-04-25 00:43:50 +02:00
rg
;; Modeline - status bar spodaj (+ ikonice)
doom-modeline
all-the-icons
;; Pomoch
helpful
;; Prikazi nedavne ukaze visje
smex
;; Programiranje
js2-mode
vue-mode
clojure-mode
;; Lepšanje fajlov na webu
web-beautify
;; Tab alignment
smart-tabs-mode
;; Dreva fajlov
treemacs
treemacs-projectile
treemacs-evil))
(setq nema (seq-filter (lambda (p) (not (package-installed-p p))) paketi))
(when nema
(package-initialize)
(package-refresh-contents)
(dolist (p nema)
(package-install p)))
;;;;;;;;;;
;; EVIL ;;
;;;;;;;;;;
2021-04-25 00:43:50 +02:00
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
(setq evil-want-keybinding nil)
(require 'evil)
2021-04-25 00:43:50 +02:00
;; Dodatni keybindi (dired, drugje)
(evil-collection-init)
(defvar my-leader-map (make-sparse-keymap)
"Mapiranje za evil bliznjice (leader trigger)")
2021-04-25 00:43:50 +02:00
;; Dodatki za orgmode / agenda podporo
(require 'evil-org)
(add-hook 'org-mode-hook 'evil-org-mode)
(evil-org-set-key-theme '(navigation insert textobjects additional calendar))
(require 'evil-org-agenda)
(evil-org-agenda-set-keys)
(setq org-agenda-files (list "~/rs/org"
"~/Dokumenti"))
;; WINDOW ukazi
(define-prefix-command 'evil-window-map)
(define-key evil-window-map "j" 'windmove-down)
(define-key evil-window-map "k" 'windmove-up)
(define-key evil-window-map "h" 'windmove-left)
(define-key evil-window-map "l" 'windmove-right)
(define-key evil-window-map "s" 'split-window-below)
(define-key evil-window-map "v" 'split-window-right)
;; BUFFER ukazi
(define-prefix-command 'evil-buffer-map)
(define-key evil-buffer-map "b" 'ivy-switch-buffer)
(define-key evil-buffer-map "p" 'previous-buffer)
(define-key evil-buffer-map "n" 'next-buffer)
(define-key evil-buffer-map "e" 'eval-buffer)
(defun switch-to-scratch () (interactive) (switch-to-buffer "*scratch*"))
(define-key evil-buffer-map "s" 'switch-to-scratch)
;; FILE ukazi
(define-prefix-command 'evil-file-map)
(define-key evil-file-map "f" 'counsel-find-file)
(defun load-config () (interactive) (find-file "~/.emacs.d/init.el"))
(define-key evil-file-map "c" 'load-config)
;; Mapiranje ukazov
(evil-global-set-key 'motion (kbd "SPC") my-leader-map)
;(define-key evil-normal-state-map (kbd "SPC") my-leader-map)
(define-key my-leader-map "w" 'evil-window-map)
(define-key my-leader-map "b" 'evil-buffer-map)
(define-key my-leader-map "f" 'evil-file-map)
(define-key my-leader-map "[" 'previous-buffer)
(define-key my-leader-map "]" 'next-buffer)
(define-key my-leader-map "r" 'counsel-bookmark)
(define-key my-leader-map "p" 'projectile-command-map)
(define-key my-leader-map "/" 'counsel-rg)
;; Odpri drevo fajlov
(define-key my-leader-map "t" 'treemacs)
;;;;;;;;;;;;;;;;;;;
;; Custom (tema) ;;
;;;;;;;;;;;;;;;;;;;
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("7661b762556018a44a29477b84757994d8386d6edee909409fabe0631952dad9" default))
2021-04-25 00:43:50 +02:00
'(iswitchb-mode t)
'(package-selected-packages
'(web-beautify vue-mode treemacs-evil treemacs-projectile treemacs smart-tabs-mode smart-tabs js2-mode smex clojure-mode helpful doom-themes counsel swiper all-the-icons doom-modeline evil-collection fennel-mode rg ivy company projectile evil))
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Iosevka SS05" :foundry "BE5N" :slant normal :weight semi-bold :height 120 :width normal)))))
;;;;;;;;;;;;;;;;
;; UI cleanup ;;
;;;;;;;;;;;;;;;;
;; Menu bar off
(menu-bar-mode -1)
(tool-bar-mode -1)
;; No dialog box plx
(setq use-dialog-box nil)
;; Brez ikon zgoraj
(setq ns-use-proxy-icon nil)
(setq frame-title-format nil)
;; Undo tree
(global-undo-tree-mode)
(evil-set-undo-system 'undo-tree)
;; Theme
2021-04-25 00:43:50 +02:00
; Skrij scrollbar
(scroll-bar-mode -1)
(setq window-divider-default-bottom-width 3)
(window-divider-mode t)
;(load-theme 'gruvbox-dark-medium t)
;(load-theme 'hemisu-light t)
(require 'doom-themes)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-gruvbox t)
(doom-themes-org-config)
;;;;;;;;;;
;; Text ;;
;;;;;;;;;;
2021-04-25 00:43:50 +02:00
;; Sirina taba ter spejsi kot distancniki
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
2021-04-25 00:43:50 +02:00
;; Editorconfig formatiranje fajlov
(editorconfig-mode 1)
2021-04-25 00:43:50 +02:00
;; Text wrap na sirino oken
(global-visual-line-mode)
;; Stevilke vrstic
(global-display-line-numbers-mode)
;; Brez stevilk vrstic v file drevesu!
(add-hook 'treemacs-mode-hook (lambda () (display-line-numbers-mode -1)))
2021-04-25 00:43:50 +02:00
;; Evil mode toggle <3
(evil-mode)
;; PhP ko je treba
(add-to-list 'auto-mode-alist '("\\.php$" . php-mode))
;; Org tudi kdaj
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
2021-04-25 00:43:50 +02:00
;; Stanja taskov
(setq org-todo-keywords
'((sequence "TODO" "V DELU" "TESTIRANJE" "DOKUMENTIRANJE" "KONČANO")))
;; DOT diagrami
(org-babel-do-load-languages
'org-babel-load-languages
'((dot . t)))
;; enable ditaa
(org-babel-do-load-languages
'org-babel-load-languages
'((ditaa . t)))
;; js2 za javascript
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(setq js2-strict-missing-semi-warning nil)
(setq js2-missing-semi-one-line-override nil)
(setq js2-basic-offset 2)
(setq js-indent-level 2)
;; Pametni tabi za js2-mode
(smart-tabs-advice js2-indent-line js2-basic-offset)
;; Kompletiranje ukazov
(company-mode)
2021-04-25 00:43:50 +02:00
;; IVY
(ivy-mode)
2021-04-25 00:43:50 +02:00
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
;; Swiper search, counsel bliznjice
(global-set-key "\C-s" 'swiper)
(define-key evil-normal-state-map (kbd "RET") 'org-open-at-point)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
;; Iskanje po fajlih (fulltext)
(rg-enable-default-bindings)
2021-04-25 00:43:50 +02:00
;; Modeline / statusbar
(require 'all-the-icons)
;; Pognat je treba (1x) all-the-icons-install-fonts
;(require 'doom-modeline)
(doom-modeline-init)
;;;;;;;;;;;
;; Razno ;;
;;;;;;;;;;;
;; Vedno sledi symlinkom v git
(setq vc-follow-symlinks t)
;; Projektni mgmt
(projectile-mode t)
;; Pomoc
;(require 'helpful)
;; Prikazi startup time
(add-to-list 'after-init-hook
(lambda ()
(message (concat "emacs (" (number-to-string (emacs-pid)) ") started in " (emacs-init-time)))))
;; Backup fajli emacsa
(setq
backup-by-copying t ; don't clobber symlinks
backup-directory-alist
'(("." . "~/.saves/")) ; don't litter my fs tree
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t) ; use versioned backups