241 lines
8.6 KiB
Plaintext
241 lines
8.6 KiB
Plaintext
;; ----------------------------
|
|
;; Podstawowa konfiguracja pakietów i MELPA
|
|
;; ----------------------------
|
|
(require 'package)
|
|
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
|
("gnu" . "https://elpa.gnu.org/packages/")))
|
|
(package-initialize)
|
|
(unless package-archive-contents
|
|
(package-refresh-contents))
|
|
|
|
;; ----------------------------
|
|
;; Instalacja i konfiguracja LSP dla Python
|
|
;; ----------------------------
|
|
(use-package lsp-mode
|
|
:ensure t
|
|
:hook ((python-mode . lsp)) ;; Automatyczne uruchamianie LSP w Python-mode
|
|
:commands lsp
|
|
:config
|
|
;; Ustawienia LSP
|
|
(setq lsp-headerline-breadcrumb-enable t) ;; Breadcrumb w nagłówku
|
|
(setq lsp-completion-provider :capf) ;; Włączenie podpowiedzi capf
|
|
(setq lsp-enable-snippet t) ;; Włączenie snippetów w podpowiedziach
|
|
(setq lsp-pyright-auto-import-completions t) ;; Automatyczne podpowiedzi importów
|
|
(setq lsp-pyright-diagnostic-mode "workspace") ;; Diagnostyka w kontekście projektu
|
|
(setq lsp-pylsp-plugins-pyflakes-enabled nil) ;; Wyłącz pyflakes
|
|
(setq lsp-pylsp-plugins-flake8-enabled t) ;; Użyj flake8 zamiast pyflakes
|
|
(setq lsp-pylsp-plugins-flake8-ignore ["F405" "F403" "E231" "E303" "E302" "E305" "E501"]) ;; Ignorowanie błędów w flake8
|
|
|
|
;; Ścieżka do interpretera Python
|
|
(setq lsp-pyright-python-executable-cmd "python3"))
|
|
|
|
|
|
|
|
(use-package lsp-ui
|
|
:ensure t
|
|
:hook (lsp-mode . lsp-ui-mode)
|
|
:config
|
|
;; Ustawienia lsp-ui
|
|
(setq lsp-ui-doc-enable t) ;; Dokumentacja w wyskakującym oknie
|
|
(setq lsp-ui-doc-position 'at-point)
|
|
(setq lsp-ui-sideline-enable t) ;; Diagnostyka w wierszu kodu
|
|
(setq lsp-ui-sideline-show-hover t) ;; Podpowiedzi w wierszu
|
|
(setq lsp-ui-sideline-show-code-actions t)) ;; Akcje kodu
|
|
|
|
|
|
;; ----------------------------
|
|
;; Flycheck - konfiguracja diagnostyki
|
|
;; ----------------------------
|
|
(use-package flycheck
|
|
:ensure t
|
|
:hook (lsp-mode . flycheck-mode)
|
|
:config
|
|
;; Priorytet diagnostyki LSP
|
|
(setq flycheck-check-syntax-automatically '(save mode-enabled))
|
|
(setq flycheck-highlighting-mode 'lines)
|
|
(setq flycheck-indication-mode 'right-fringe))
|
|
|
|
(use-package lsp-ui-flycheck
|
|
:after (lsp-mode flycheck)
|
|
:ensure nil)
|
|
|
|
|
|
;; Obsługa wirtualnych środowisk Python (pyvenv)
|
|
;; ----------------------------
|
|
(use-package pyvenv
|
|
:ensure t
|
|
:config
|
|
;; Automatyczna aktywacja środowiska venv w katalogu projektu
|
|
(defun my-auto-activate-venv ()
|
|
"Automatycznie aktywuj venv w bieżącym katalogu projektu."
|
|
(let ((venv-path (locate-dominating-file default-directory "venv")))
|
|
(when venv-path
|
|
(pyvenv-activate (expand-file-name "venv" venv-path))
|
|
(setq lsp-pyright-python-executable-cmd (expand-file-name "bin/python" venv-path)))))
|
|
(add-hook 'python-mode-hook #'my-auto-activate-venv)
|
|
|
|
;; Dodanie informacji o aktywnym venv do modeline
|
|
(defun my-get-current-venv ()
|
|
"Zwraca nazwę aktywnego środowiska wirtualnego."
|
|
(if (and (boundp 'pyvenv-virtual-env) pyvenv-virtual-env)
|
|
(propertize (concat "venv: " (file-name-nondirectory (directory-file-name pyvenv-virtual-env)))
|
|
'face '(:foreground "green"))
|
|
"No venv"))
|
|
|
|
(setq-default mode-line-format
|
|
(append mode-line-format
|
|
'((:eval (my-get-current-venv))))))
|
|
|
|
;; Skróty klawiszowe dla pyvenv
|
|
(global-set-key (kbd "C-c v a") 'pyvenv-activate) ;; Aktywuj środowisko
|
|
(global-set-key (kbd "C-c v d") 'pyvenv-deactivate) ;; Dezaktywuj środowisko
|
|
(global-set-key (kbd "C-c v w") 'pyvenv-workon) ;; Przełącz środowisko (workon)
|
|
|
|
;; ----------------------------
|
|
;; System podpowiedzi: Company
|
|
;; ----------------------------
|
|
(use-package company
|
|
:ensure t
|
|
:hook (lsp-mode . company-mode)
|
|
:config
|
|
(setq company-idle-delay 0.2) ;; Opóźnienie podpowiedzi
|
|
(setq company-minimum-prefix-length 1) ;; Minimalna długość prefiksu dla podpowiedzi
|
|
(setq company-selection-wrap-around t)) ;; Zawijanie w menu podpowiedzi
|
|
|
|
;; ----------------------------
|
|
;; Magit i zarządzanie projektami
|
|
;; ----------------------------
|
|
(use-package magit
|
|
:ensure t
|
|
:config
|
|
(setq magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
|
|
|
|
(use-package treemacs
|
|
:ensure t
|
|
:config
|
|
(global-set-key (kbd "C-c t") 'treemacs) ;; Skrót do otwierania Treemacs
|
|
(setq treemacs-position 'right) ;; Pozycja drzewa po prawej stronie
|
|
(setq treemacs-follow-mode t) ;; Automatyczne śledzenie otwartego pliku
|
|
(setq treemacs-filewatch-mode t) ;; Automatyczne odświeżanie
|
|
(setq treemacs-git-mode 'deferred)) ;; Obsługa Git w Treemacs
|
|
|
|
(use-package lsp-treemacs
|
|
:ensure t
|
|
:after (lsp-mode treemacs)
|
|
:config
|
|
(lsp-treemacs-sync-mode 1))
|
|
|
|
;; ----------------------------
|
|
;; Ulepszenia interfejsu: which-key
|
|
;; ----------------------------
|
|
(use-package which-key
|
|
:ensure t
|
|
:config
|
|
(which-key-mode)
|
|
(setq which-key-idle-delay 0.5) ;; Opóźnienie wyświetlania podpowiedzi
|
|
(setq which-key-idle-secondary-delay 0.1))
|
|
|
|
;; ----------------------------
|
|
;; Konfiguracja Evil i lidera (leader key)
|
|
;; ----------------------------
|
|
(use-package evil
|
|
:ensure t
|
|
:config
|
|
(evil-mode 1))
|
|
|
|
(use-package evil-leader
|
|
:ensure t
|
|
:config
|
|
(global-evil-leader-mode)
|
|
(evil-leader/set-leader "<SPC>")
|
|
(evil-leader/set-key
|
|
"g g" 'magit-status
|
|
"f f" 'find-file
|
|
"b b" 'switch-to-buffer
|
|
"b m" 'buffer-menu
|
|
"t t" 'treemacs
|
|
"t a" 'treemacs-add-project-to-workspace
|
|
"t r" 'treemacs-remove-project-from-workspace
|
|
"t c" 'treemacs-copy-file
|
|
|
|
))
|
|
|
|
|
|
|
|
;; ----------------------------
|
|
;; Dodanie obsługi komentowania za pomocą "gc"
|
|
;; ----------------------------
|
|
(use-package evil-commentary
|
|
:ensure t
|
|
:after evil
|
|
:config
|
|
(evil-commentary-mode))
|
|
|
|
|
|
;; ----------------------------
|
|
;; Wygląd: Motyw i minimalistyczny interfejs
|
|
;; ----------------------------
|
|
(use-package gruvbox-theme
|
|
:ensure t
|
|
:config
|
|
(load-theme 'gruvbox-dark-medium t))
|
|
|
|
(tool-bar-mode -1)
|
|
(menu-bar-mode -1)
|
|
(scroll-bar-mode -1)
|
|
(setq inhibit-startup-message t)
|
|
|
|
|
|
;; ----------------------------
|
|
;; Formatowanie kodu z Black
|
|
;; ----------------------------
|
|
(use-package blacken
|
|
:ensure t
|
|
:hook (python-mode . blacken-mode)
|
|
:config
|
|
(setq blacken-line-length 88))
|
|
|
|
|
|
;; ----------------------------
|
|
;; Podsumowanie i test
|
|
;; ----------------------------
|
|
(recentf-mode 1)
|
|
(setq recentf-max-menu-items 25) ;; Maksymalna liczba plików na liście
|
|
(global-set-key (kbd "C-c r") 'recentf-open-files) ;; Skrót do ostatnich plików
|
|
|
|
;; ----------------------------
|
|
;; Other keys
|
|
;; ----------------------------
|
|
(global-set-key (kbd "C-c e") 'eshell)
|
|
(global-set-key (kbd "C-c d") 'flymake-show-buffer-diagnostics)
|
|
|
|
(global-set-key (kbd "C-c j s") 'jupyter-run-server-repl) ;; Połącz się z serwerem
|
|
(global-set-key (kbd "C-c j a") 'jupyter-repl-associate-buffer) ;; Powiąż bufor z REPL
|
|
(global-set-key (kbd "C-c j b") 'jupyter-eval-buffer) ;; Wykonaj cały bufor
|
|
|
|
(setq initial-scratch-message (concat ";; Aby otworzyć org daj na C-c o\n"
|
|
";; Aby otworzyć ostatnie pliki daj na C-c r\n"
|
|
";; Aby otworzyć treemacs daj na C-c t \n"
|
|
";; Aktywacja środowiska pyenv C-c v a \n"
|
|
";; Eshell C-c e \n"
|
|
";; Pokaż błędy flymake C-c d \n"
|
|
"\n"
|
|
";;Jupyter \n"
|
|
";;Wykonaj Połącz się z serwerem C-c j s \n"
|
|
";;Powiazanie bufora REPL C-c j a \n"
|
|
";;Wykonaj cały bufor C-c j b \n"
|
|
";;Wykkonaj region C-c C-c \n"))
|
|
(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.
|
|
'(package-selected-packages
|
|
'(evil-commentary yasnippet which-key vterm request pyvenv polymode neotree magit lsp-ui lsp-treemacs jupyter highlight-indentation gruvbox-theme evil-org evil-leader deferred company anaphora)))
|
|
(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.
|
|
)
|