Kilka poprawek z paskiem

This commit is contained in:
Rafał Paluch 2025-04-06 13:49:12 +02:00
parent d2ed4e7136
commit 52a7f580a4
6 changed files with 1527 additions and 502 deletions

810
Kopia_init.el Normal file
View File

@ -0,0 +1,810 @@
;; ----------------------------
;; Podstawowa konfiguracja pakietów i MELPA
;; ----------------------------
(require 'package)
;; Dodaj repozytoria
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("org" . "https://orgmode.org/elpa/")))
;; Inicjalizuj system pakietów
(package-initialize)
;; Odśwież listę pakietów, jeśli jest pusta
(unless package-archive-contents
(package-refresh-contents))
;; Funkcja do instalowania pakietów
(defun ensure-package-installed (&rest packages)
"Ensure that the given PACKAGES are installed.
Missing packages are automatically installed."
(dolist (package packages)
(unless (package-installed-p package)
(package-install package))))
(cond
((eq system-type 'windows-nt)
;; Konfiguracja dla Windows
(setq browse-url-browser-function 'browse-url-firefox)
(setq browse-url-firefox-program "C:/Program Files/Mozilla Firefox/firefox.exe"))
((eq system-type 'gnu/linux)
;; Konfiguracja dla Linux
(setq browse-url-browser-function 'browse-url-firefox)))
;; Instalacja wymaganych pakietów
(ensure-package-installed
'use-package
'vterm
'magit
'blacken
'pyvenv
'lsp-mode
'lsp-ui
'flycheck
'org-roam
'company
'jupyter
'scad-mode
'treemacs
'yasnippet
'winum
'lsp-treemacs)
(require 'scad-mode)
(add-to-list 'auto-mode-alist '("\\.scad\\'" . scad-mode))
(defun scad-preview ()
"Render OpenSCAD file using the openscad command."
(interactive)
(let ((file-name (buffer-file-name)))
(if file-name
(start-process "openscad" "*OpenSCAD*" "openscad" file-name)
(message "Buffer is not visiting a file"))))
(define-key scad-mode-map (kbd "C-c C-r") 'scad-preview)
;; Wczytaj i skonfiguruj `use-package`
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(when (eq system-type 'windows-nt)
;; Popraw kodowanie dla Windows
(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8))
;; python offset
(setq python-indent-guess-indent-offset nil)
(setq python-indent-offset 4)
(setq python-indent-guess-indent-offset-verbose nil)
;; ----------------------------
;; Image Clipboard
;; ----------------------------
;; (defun save-image-from-clipboard ()
;; "Save an image from clipboard as a PNG file, scale it, and insert a link in Org Mode."
;; (interactive)
;; (let* ((dir "~/Nextcloud/org_images/") ;; Katalog docelowy
;; (system-type-command
;; (if (eq system-type 'windows-nt)
;; "powershell -Command \"Get-Clipboard -Format Image | Set-Content -Path '%s' -AsByteStream\""
;; "xclip -selection clipboard -t image/png -o > %s"))
;; (filename (generate-unique-filename dir "image" "png")) ;; Automatyczna nazwa
;; (file-path (concat (file-name-as-directory dir) filename))) ;; Pełna ścieżka
;; (make-directory dir :parents) ;; Tworzenie katalogu, jeśli nie istnieje
;; (if (eq 0 (call-process-shell-command (format system-type-command file-path)))
;; (progn
;; (scale-image file-path 400) ;; Skalowanie obrazu do szerokości 400 px
;; (insert (format "[[file:%s]]" file-path)) ;; Wstaw link w buforze
;; (org-display-inline-images) ;; Wyświetl obraz w buforze Org Mode
;; (message "Image saved to: %s" file-path))
;; (message "Error: No image in clipboard or unsupported format."))))
;; (defun generate-unique-filename (dir prefix extension)
;; "Generate a unique filename in DIR with PREFIX and EXTENSION."
;; (let ((counter 1)
;; (filename ""))
;; (while (progn
;; (setq filename (format "%s-%d.%s" prefix counter extension))
;; (file-exists-p (concat (file-name-as-directory dir) filename)))
;; (setq counter (1+ counter)))
;; filename))
;; (defun scale-image (file-path max-width)
;; "Scale the image at FILE-PATH to MAX-WIDTH using ImageMagick's convert."
;; (call-process-shell-command
;; (format "convert %s -resize %d %s" file-path max-width file-path)))
;; Test
(defun save-image-from-clipboard ()
"Save an image from clipboard as a PNG file, scale it, and insert a link in Org Mode."
(interactive)
(let* ((dir (if (eq system-type 'windows-nt)
"C:/Users/paluc/Nextcloud/org_images/" ;; Katalog dla Windows
"~/Nextcloud/org_images/")) ;; Katalog dla Linux
(system-type-command
(if (eq system-type 'windows-nt)
;; Polecenie dla Windows
"powershell -Command \"Add-Type -AssemblyName System.Drawing; Add-Type -AssemblyName System.Windows.Forms; $image = [System.Windows.Forms.Clipboard]::GetImage(); if ($image -ne $null) { $image.Save('%s', [System.Drawing.Imaging.ImageFormat]::Png) } else { exit 1 }\""
;; Polecenie dla Linux
"xclip -selection clipboard -t image/png -o > %s"))
(filename (generate-unique-filename dir "image" "png")) ;; Automatyczna nazwa
(file-path (concat (file-name-as-directory dir) filename))) ;; Pełna ścieżka
(make-directory dir :parents) ;; Tworzenie katalogu, jeśli nie istnieje
(if (eq 0 (call-process-shell-command (format system-type-command file-path)))
(progn
(scale-image file-path 400) ;; Skalowanie obrazu do szerokości 400 px
(insert (format "[[file:%s]]" (convert-path-to-org file-path))) ;; Wstaw link w buforze
(org-display-inline-images) ;; Wyświetl obraz w buforze Org Mode
(message "Image saved to: %s" file-path))
(message "Error: No image in clipboard or unsupported format."))))
(defun generate-unique-filename (dir prefix extension)
"Generate a unique filename in DIR with PREFIX and EXTENSION."
(let ((counter 1)
(filename ""))
(while (progn
(setq filename (format "%s-%d.%s" prefix counter extension))
(file-exists-p (concat (file-name-as-directory dir) filename)))
(setq counter (1+ counter)))
filename))
(defun scale-image (file-path max-width)
"Scale the image at FILE-PATH to MAX-WIDTH using ImageMagick's convert."
(call-process-shell-command
(format "convert %s -resize %d %s" file-path max-width file-path)))
(defun convert-path-to-org (path)
"Convert Windows paths to Org-compatible paths."
(if (eq system-type 'windows-nt)
(replace-regexp-in-string "\\\\" "/" path) ;; Zamiana backslash na slash
path)) ;; Dla Linux nic nie zmieniamy
;; ----------------------------
;; Podstawowa konfiguracja Org-Roam
;; ----------------------------
;; Definicja ścieżek dla Org-roam
(setq my-org-roam-windows-path "C:/Users/paluc/Nextcloud/org/roam/")
(setq my-org-roam-linux-path "~/Nextcloud/org/roam/")
(defun my-set-org-roam-directory ()
"Ustaw katalog Org-roam w zależności od systemu operacyjnego."
(setq org-roam-directory
(file-truename
(if (eq system-type 'windows-nt)
my-org-roam-windows-path
my-org-roam-linux-path))))
;; Wywołaj funkcję przy starcie Emacs
(my-set-org-roam-directory)
;; Konfiguracja Org-roam
(use-package org-roam
:ensure t
:bind (("C-c n l" . org-roam-buffer-toggle) ;; Bufor backlinków
("C-c n f" . org-roam-node-find) ;; Wyszukiwanie notatek
("C-c n g" . org-roam-graph) ;; Graf powiązań
("C-c n c" . org-roam-capture)) ;; Tworzenie nowej notatki
:config
(org-roam-db-autosync-mode)) ;; Automatyczna synchronizacja bazy danych
;; Ścieżka do programu "dot" (Graphviz)
(setq org-roam-graph-executable "dot")
;; Format pliku wyjściowego
(setq org-roam-graph-output "png") ;; Możliwe opcje: "svg", "png", "pdf"
;; Dodatkowe opcje dla generowanego grafu
(setq org-roam-graph-extra-config
'(("overlap" . "scale") ;; Unikaj nakładania się węzłów
("splines" . "true") ;; Pokaż linie jako krzywe
("sep" . "25"))) ;; Odstępy między węzłami
(setq org-roam-graph-file
(expand-file-name "org-roam-graph.png" org-roam-directory))
;; ----------------------------
;; Winum
;; ----------------------------
;; Przełączanie się między oknami
(use-package winum
:ensure t
:config
(winum-mode))
;; ----------------------------
;; Konfiguracja yasnippet
;; ----------------------------
(use-package yasnippet
:ensure t
:config
(yas-global-mode 1)) ;; Włącz YASnippet globalnie
(setq yas-snippet-dirs '("~/.emacs.d/snippets")) ;; Ścieżka do własnych snippetów
(use-package yasnippet-snippets
:ensure t
:after yasnippet) ;; Wymaga załadowanego yasnippet
;; ----------------------------
;; Konfiguracja org-mode
;; ----------------------------
(setq org-file-apps
`((auto-mode . emacs)
("\\.pdf\\'" . ,(if (eq system-type 'windows-nt)
"C:/Users/paluc/AppData/Local/SumatraPDF/SumatraPDF.exe %s"
"xdg-open %s"))))
;; Automatyczne generowanie linku
(setq org-attach-directory "files")
(setq org-attach-automatic-link t)
;; Definicja ścieżek dla Windows i Linux
(setq my-org-agenda-windows-path "C:/Users/paluc/Nextcloud/org/")
(setq my-org-agenda-linux-path "~/Nextcloud/org/")
;; Definicja ścieżek do pliku todo.org
(setq my-todo-file-windows "C:/Users/paluc/Nextcloud/org/todo.org")
(setq my-todo-file-linux "~/Nextcloud/org/todo.org")
(setq my-note-file-windows "C:/Users/paluc/Nextcloud/org/orther.org")
(setq my-note-file-linux "~/Nextcloud/todo/other.org")
;; Funkcja ustawiająca odpowiednią ścieżkę na podstawie systemu
(defun my-set-org-agenda-files ()
"Ustaw pliki agendy Org w zależności od systemu operacyjnego."
(setq org-agenda-files
(directory-files-recursively
(if (eq system-type 'windows-nt)
my-org-agenda-windows-path
my-org-agenda-linux-path)
"\\.org$")))
;; Wywołaj funkcję przy starcie Emacs
(my-set-org-agenda-files)
;; Funkcja otwierająca plik todo.org
(defun my-open-todo-file ()
"Otwórz plik todo.org w zależności od systemu operacyjnego."
(interactive)
(let ((note-file (if (eq system-type 'windows-nt)
my-todo-file-windows
my-todo-file-linux)))
(if (file-exists-p note-file)
(find-file note-file)
(message "Plik todo.org nie istnieje: %s" note-file))))
(defun my-open-note-file ()
"Otwórz plik todo.org w zależności od systemu operacyjnego."
(interactive)
(let ((todo-file (if (eq system-type 'windows-nt)
my-note-file-windows
my-note-file-linux)))
(if (file-exists-p todo-file)
(find-file todo-file)
(message "Plik todo.org nie istnieje: %s" todo-file))))
;; Włącz org-mode automatycznie dla plików .org
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
;; Włącz folding w org-mode (skróty klawiszowe)
(setq org-startup-folded t) ;; Start with folded headlines
(setq org-hide-leading-stars t) ;; Ukrywanie gwiazdek poza pierwszym poziomem
(setq org-ellipsis "") ;; Znak na końcu zwiniętych sekcji
;; Ustawienia klawisza TAB w org-mode przy użyciu Evil
(add-hook 'org-mode-hook
(lambda ()
(evil-define-key 'normal org-mode-map (kbd "TAB") 'org-cycle)
(evil-define-key 'normal org-mode-map (kbd "S-TAB") 'org-shifttab)))
;; Podświetlanie składni i elementów w org-mode
(setq org-fontify-whole-heading-line t) ;; Podświetlaj cały nagłówek
(setq org-fontify-done-headline t) ;; Podświetlaj ukończone nagłówki
(setq org-fontify-quote-and-verse-blocks t) ;; Podświetlaj bloki cytatów i wierszy
;; Automatyczne podświetlanie kodu w blokach źródłowych
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
;; Wsparcie dla hierarchicznego folding w org-mode
(setq org-cycle-separator-lines 2) ;; Próg zwijania między sekcjami
;; Wygląd i czytelność w org-mode
(setq org-hide-emphasis-markers t) ;; Ukryj znaki formatowania (*bold*, /italic/)
(setq org-pretty-entities t) ;; Wyświetl symbole matematyczne jako unicode
(setq org-highlight-latex-and-related '(latex script entities)) ;; Podświetlaj LaTeX
;; Współpraca z tytułami i nagłówkami
(setq org-startup-indented t) ;; Włącz automatyczne wcięcia
(setq org-indent-mode-turns-on-hiding-stars t) ;; Ukryj gwiazdki w nagłówkach
;; Funkcje dodatkowe
(setq org-log-done 'time) ;; Zapisuj czas oznaczenia zadania jako DONE
(setq org-return-follows-link t) ;; ENTER podąża za linkami
;; ----------------------------
;; 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-default flycheck-disabled-checkers '(python-pylint python-flake8))
(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-diagnostics-provider :none) ;; Wyłącz diagnostykę LSP na rzecz Flycheck
(setq lsp-pylsp-plugins-ruff-enabled t) ;; Użyj flake8 zamiast pyflakes
;; Ś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) ;; Włącz Flycheck w trybie LSP
(emacs-lisp-mode . flycheck-mode)) ;; Włącz Flycheck w trybie Emacs Lisp
: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)
(defun set-flycheck-executables ()
"Set Flycheck executables to use from the active Python virtual environment."
(when (and (boundp 'pyvenv-virtual-env) pyvenv-virtual-env)
(let* ((flake8-path (concat pyvenv-virtual-env
(if (eq system-type 'windows-nt)
"/Scripts/flake8.exe" ; Ścieżka na Windows
"/bin/flake8"))) ; Ścieżka na Linux/Mac
(pylint-path (concat pyvenv-virtual-env
(if (eq system-type 'windows-nt)
"/Scripts/pylint.exe" ; Ścieżka na Windows
"/bin/pylint")))) ; Ścieżka na Linux/Mac
(when (file-executable-p flake8-path)
(flycheck-set-checker-executable 'python-flake8 flake8-path))
(when (file-executable-p pylint-path)
(flycheck-set-checker-executable 'python-pylint pylint-path)))))
(add-hook 'flycheck-before-syntax-check-hook #'set-flycheck-executables)
;; 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)
;; (add-hook 'pyvenv-post-activate-hooks #'my-update-pyvenv-modeline)
;; (add-hook 'pyvenv-post-deactivate-hooks #'my-update-pyvenv-modeline)
;; ----------------------------
;; 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)
;; turbo
;; ----------------------------
(use-package evil
:ensure t
:config
(evil-mode 1))
(evil-ex-define-cmd "hs" 'split-window-below)
(use-package evil-leader
:ensure t
:config
(global-evil-leader-mode)
(evil-leader/set-leader "<SPC>")
(evil-leader/set-key
"g g" 'magit-status
"o o" 'my-open-todo-file
"o n" 'my-open-note-file
"o t" 'org-toggle-inline-imageS
"o f" 'org-overview
"o c" 'org-insert-link
"o l" 'org-agenda-list
"o i" 'org-clock-in
"o s" 'org-clock-out
"o r" 'org-clock-report
"r i" 'org-roam-node-insert
"g a" 'magit-remote-add
"g p" 'magit-pull
"g n" 'remote-nadpisz
"m b" 'build123d
"m v" 'vosk-start
"f f" 'find-file
"b l" 'ibuffer
"b w" 'buffer-menu-open
"t t" 'treemacs
"t a" 'treemacs-add-project-to-workspace
"t r" 'treemacs-remove-project-from-workspace
"t c" 'treemacs-copy-file
"t f" 'treemacs-create-file
"t m" 'treemacs-rename-file
"l l" 'toggle-truncate-lines
"l n" 'display-line-numbers-mode
"j s" 'jupyter-run-server-repl
"j a" 'jupyter-repl-associate-buffer
"s r" 'query-replace
"e l" 'flycheck-list-errors
"n n" 'narrow-to-region
"n w" 'widen
"a" 'mark-whole-buffer
"TAB" (lambda () (interactive) (switch-to-buffer (other-buffer)))
"1" 'winum-select-window-1
"2" 'winum-select-window-2
"3" 'winum-select-window-3
"4" 'winum-select-window-4
"5" 'winum-select-window-5))
(which-key-add-key-based-replacements
"<SPC> g" "Magit"
"<SPC> e" "Errors"
"<SPC> n" "Narrow"
"<SPC> f" "Files"
"<SPC> b" "Buffers"
"<SPC> t" "Treemacs"
"<SPC> l" "Lines"
"<SPC> j" "Jupyter"
"<SPC> s" "Search&Replace"
"<SPC> o" "Org"
"<SPC> m" "Macro"
)
;; Utwórz mapę klawiszy dla "SPC"
(define-prefix-command 'my-space-prefix)
(define-key evil-normal-state-map (kbd "SPC") 'my-space-prefix)
;; Dodaj mapowanie "SPC 0" do Treemacs
(define-key my-space-prefix (kbd "0") 'my-treemacs-select-or-open)
;; Funkcja, która przełącza się na okno Treemacs lub je otwiera
(defun my-treemacs-select-or-open ()
"Przełącz się na okno Treemacs lub otwórz Treemacs, jeśli nie jest aktywne."
(interactive)
(if (treemacs-get-local-window)
(treemacs-select-window)
(treemacs)))
;; ----------------------------
;; 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") 'flycheck-list-errors)
(global-set-key (kbd "C-c o f") 'save-image-from-clipboard) ;; Zapisz zdjęcie
(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 todo daj na SPC o o \n"
";; Aby otworzyć org notatki daj na SPC o n \n"
";; Otwarcie menu attachment C-c C-a \n"
";; Otwarcie załącznika attachment C-c C-a o \n"
";; Otwarcie załącznika attachment C-c C-a o \n"
";; Zapisanie zdjęcia w org C-c o f \n"
";; Dodanie linku SPC o c \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 flycheck 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
'(org-roam 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.
)
(put 'narrow-to-region 'disabled nil)
;; ----------------------------
;; Moje makra
;; ----------------------------
(defun vosk-start ()
"Start Vosk script in the appropriate environment."
(interactive)
(let ((file-path (if (eq system-type 'windows-nt)
"C:/Users/paluc/OneDrive/Dokumenty/vosk/voskpl.py"
"~/vosk/voskpl.py")))
;; Przejdź do voskpl.py
(find-file file-path)
;; Otwórz eshell i uruchom vosk
(eshell 100)
(insert (format "python %s" file-path))
(eshell-send-input)))
(defun build123d ()
"Automatyzacja workflow: uruchomienie Jupyter Lab, OCP VSCode i konfiguracja REPL."
(interactive)
;; Przejdź do pliku simrig.py
(let ((file-path (if (eq system-type 'windows-nt)
"C:/Users/paluc/OneDrive/Dokumenty/simrig2/simrig.py"
"/home/pali112/Dokumenty/simrig2/simrig.py")))
(find-file file-path)
;; Otwórz eshell 1 i uruchom Jupyter Lab
(eshell 1)
(sleep-for 1) ;; Czekaj na aktywację pipenv shell
(insert "jupyter lab")
(eshell-send-input)
(sleep-for 3) ;; Czekaj na aktywację pipenv shell
;; Przejdź do eshell 2 i uruchom Python -m ocp_vscode
(eshell 2)
(sleep-for 1) ;; Czekaj na aktywację pipenv shell
(insert "python -m ocp_vscode")
(eshell-send-input)
(sleep-for 1) ;; Czekaj na aktywację pipenv shell
;; Powróć do pliku simrig.py
(find-file file-path)
;; Uruchom jupyter-run-server-repl i pozwól użytkownikowi potwierdzić wartości interaktywnie
(call-interactively 'jupyter-run-server-repl)
(sleep-for 1) ;; Czekaj na aktywację pipenv shell
(find-file file-path)
(call-interactively 'jupyter-repl-associate-buffer)
;; Otwórz stronę w przeglądarce
(browse-url "http://localhost:3939/viewer")))
(defun remote-nadpisz ()
"Fetch changes from remote, reset local branch, and clean untracked files."
(interactive)
(let ((eshell-buffer (generate-new-buffer "*eshell*")))
(with-current-buffer eshell-buffer
(eshell-mode)
(goto-char (point-max))
(insert "git fetch origin && git reset --hard origin/master && git clean -fd")
(eshell-send-input) ;; Wykonuje komendę
(insert "exit")
(eshell-send-input))
(switch-to-buffer eshell-buffer))) ;; Przełącza się do nowego bufora
;; Funkcja tworząca pusty plik .gitignore w Emacs
(defun create-gitignore (directory)
"Tworzy pusty plik .gitignore w podanym katalogu DIRECTORY."
(interactive "DChoose directory: ")
(let ((gitignore-path (expand-file-name ".gitignore" directory)))
(if (file-exists-p gitignore-path)
(message "Plik .gitignore już istnieje w katalogu %s" directory)
(with-temp-file gitignore-path
(insert ""))
(message "Pusty plik .gitignore został utworzony w katalogu %s" directory))))
;; Aby użyć tej funkcji, wpisz M-x create-gitignore i wskaż katalog, w którym ma być utworzony pusty plik.

View File

@ -1,240 +0,0 @@
;; ----------------------------
;; 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.
)

614
init.el
View File

@ -26,24 +26,50 @@ Missing packages are automatically installed."
(package-install package))))
(cond
((eq system-type 'windows-nt)
;; Konfiguracja dla Windows
(setq browse-url-browser-function 'browse-url-firefox)
(setq browse-url-firefox-program "C:/Program Files/Mozilla Firefox/firefox.exe"))
((eq system-type 'gnu/linux)
;; Konfiguracja dla Linux
(setq browse-url-browser-function 'browse-url-firefox)))
;; Instalacja wymaganych pakietów
(ensure-package-installed
'use-package
'vterm
'magit
'blacken
'pyvenv
'lsp-mode
'lsp-ui
'flycheck
'org-roam
'company
'jupyter
'scad-mode
'treemacs
'yasnippet
'winum
'lsp-treemacs)
(require 'scad-mode)
(add-to-list 'auto-mode-alist '("\\.scad\\'" . scad-mode))
(defun scad-preview ()
"Render OpenSCAD file using the openscad command."
(interactive)
(let ((file-name (buffer-file-name)))
(if file-name
(start-process "openscad" "*OpenSCAD*" "openscad" file-name)
(message "Buffer is not visiting a file"))))
(define-key scad-mode-map (kbd "C-c C-r") 'scad-preview)
;; Wczytaj i skonfiguruj `use-package`
(unless (package-installed-p 'use-package)
(package-install 'use-package))
@ -51,6 +77,160 @@ Missing packages are automatically installed."
(setq use-package-always-ensure t)
(when (eq system-type 'windows-nt)
;; Popraw kodowanie dla Windows
(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8))
;; python offset
(setq python-indent-guess-indent-offset nil)
(setq python-indent-offset 4)
(setq python-indent-guess-indent-offset-verbose nil)
;; ----------------------------
;; Image Clipboard
;; ----------------------------
;; (defun save-image-from-clipboard ()
;; "Save an image from clipboard as a PNG file, scale it, and insert a link in Org Mode."
;; (interactive)
;; (let* ((dir "~/Nextcloud/org_images/") ;; Katalog docelowy
;; (system-type-command
;; (if (eq system-type 'windows-nt)
;; "powershell -Command \"Get-Clipboard -Format Image | Set-Content -Path '%s' -AsByteStream\""
;; "xclip -selection clipboard -t image/png -o > %s"))
;; (filename (generate-unique-filename dir "image" "png")) ;; Automatyczna nazwa
;; (file-path (concat (file-name-as-directory dir) filename))) ;; Pełna ścieżka
;; (make-directory dir :parents) ;; Tworzenie katalogu, jeśli nie istnieje
;; (if (eq 0 (call-process-shell-command (format system-type-command file-path)))
;; (progn
;; (scale-image file-path 400) ;; Skalowanie obrazu do szerokości 400 px
;; (insert (format "[[file:%s]]" file-path)) ;; Wstaw link w buforze
;; (org-display-inline-images) ;; Wyświetl obraz w buforze Org Mode
;; (message "Image saved to: %s" file-path))
;; (message "Error: No image in clipboard or unsupported format."))))
;; (defun generate-unique-filename (dir prefix extension)
;; "Generate a unique filename in DIR with PREFIX and EXTENSION."
;; (let ((counter 1)
;; (filename ""))
;; (while (progn
;; (setq filename (format "%s-%d.%s" prefix counter extension))
;; (file-exists-p (concat (file-name-as-directory dir) filename)))
;; (setq counter (1+ counter)))
;; filename))
;; (defun scale-image (file-path max-width)
;; "Scale the image at FILE-PATH to MAX-WIDTH using ImageMagick's convert."
;; (call-process-shell-command
;; (format "convert %s -resize %d %s" file-path max-width file-path)))
;; Test
(defun save-image-from-clipboard ()
"Save an image from clipboard as a PNG file, scale it, and insert a link in Org Mode."
(interactive)
(let* ((dir (if (eq system-type 'windows-nt)
"C:/Users/paluc/Nextcloud/org_images/" ;; Katalog dla Windows
"~/Nextcloud/org_images/")) ;; Katalog dla Linux
(system-type-command
(if (eq system-type 'windows-nt)
;; Polecenie dla Windows
"powershell -Command \"Add-Type -AssemblyName System.Drawing; Add-Type -AssemblyName System.Windows.Forms; $image = [System.Windows.Forms.Clipboard]::GetImage(); if ($image -ne $null) { $image.Save('%s', [System.Drawing.Imaging.ImageFormat]::Png) } else { exit 1 }\""
;; Polecenie dla Linux
"xclip -selection clipboard -t image/png -o > %s"))
(filename (generate-unique-filename dir "image" "png")) ;; Automatyczna nazwa
(file-path (concat (file-name-as-directory dir) filename))) ;; Pełna ścieżka
(make-directory dir :parents) ;; Tworzenie katalogu, jeśli nie istnieje
(if (eq 0 (call-process-shell-command (format system-type-command file-path)))
(progn
(scale-image file-path 400) ;; Skalowanie obrazu do szerokości 400 px
(insert (format "[[file:%s]]" (convert-path-to-org file-path))) ;; Wstaw link w buforze
(org-display-inline-images) ;; Wyświetl obraz w buforze Org Mode
(message "Image saved to: %s" file-path))
(message "Error: No image in clipboard or unsupported format."))))
(defun generate-unique-filename (dir prefix extension)
"Generate a unique filename in DIR with PREFIX and EXTENSION."
(let ((counter 1)
(filename ""))
(while (progn
(setq filename (format "%s-%d.%s" prefix counter extension))
(file-exists-p (concat (file-name-as-directory dir) filename)))
(setq counter (1+ counter)))
filename))
(defun scale-image (file-path max-width)
"Scale the image at FILE-PATH to MAX-WIDTH using ImageMagick's convert."
(call-process-shell-command
(format "convert %s -resize %d %s" file-path max-width file-path)))
(defun convert-path-to-org (path)
"Convert Windows paths to Org-compatible paths."
(if (eq system-type 'windows-nt)
(replace-regexp-in-string "\\\\" "/" path) ;; Zamiana backslash na slash
path)) ;; Dla Linux nic nie zmieniamy
;; ----------------------------
;; Podstawowa konfiguracja Org-Roam
;; ----------------------------
;; Definicja ścieżek dla Org-roam
(setq my-org-roam-windows-path "C:/Users/paluc/Nextcloud/org/roam/")
(setq my-org-roam-linux-path "~/Nextcloud/org/roam/")
(defun my-set-org-roam-directory ()
"Ustaw katalog Org-roam w zależności od systemu operacyjnego."
(setq org-roam-directory
(file-truename
(if (eq system-type 'windows-nt)
my-org-roam-windows-path
my-org-roam-linux-path))))
;; Wywołaj funkcję przy starcie Emacs
(my-set-org-roam-directory)
;; Konfiguracja Org-roam
(use-package org-roam
:ensure t
:bind (("C-c n l" . org-roam-buffer-toggle) ;; Bufor backlinków
("C-c n f" . org-roam-node-find) ;; Wyszukiwanie notatek
("C-c n g" . org-roam-graph) ;; Graf powiązań
("C-c n c" . org-roam-capture)) ;; Tworzenie nowej notatki
:config
(org-roam-db-autosync-mode)) ;; Automatyczna synchronizacja bazy danych
;; Ścieżka do programu "dot" (Graphviz)
(setq org-roam-graph-executable "dot")
;; Format pliku wyjściowego
(setq org-roam-graph-output "png") ;; Możliwe opcje: "svg", "png", "pdf"
;; Dodatkowe opcje dla generowanego grafu
(setq org-roam-graph-extra-config
'(("overlap" . "scale") ;; Unikaj nakładania się węzłów
("splines" . "true") ;; Pokaż linie jako krzywe
("sep" . "25"))) ;; Odstępy między węzłami
(setq org-roam-graph-file
(expand-file-name "org-roam-graph.png" org-roam-directory))
;; ----------------------------
;; Winum
;; ----------------------------
;; Przełączanie się między oknami
(use-package winum
@ -78,19 +258,36 @@ Missing packages are automatically installed."
:after yasnippet) ;; Wymaga załadowanego yasnippet
;; ----------------------------
;; Konfiguracja org-mode
;; ----------------------------
(with-eval-after-load 'org
(evil-define-key 'normal org-mode-map
(kbd "L") 'org-do-demote
(kbd "H") 'org-do-promote))
(setq org-file-apps
`((auto-mode . emacs)
("\\.pdf\\'" . ,(if (eq system-type 'windows-nt)
"C:/Users/paluc/AppData/Local/SumatraPDF/SumatraPDF.exe %s"
"xdg-open %s"))))
;; Automatyczne generowanie linku
(setq org-attach-directory "files")
(setq org-attach-automatic-link t)
;; Definicja ścieżek dla Windows i Linux
(setq my-org-agenda-windows-path "C:/Users/TwojaNazwaUżytkownika/Documents/org/")
(setq my-org-agenda-linux-path "~/Nextcloud/todo/")
(setq my-org-agenda-windows-path "C:/Users/paluc/Nextcloud/org/")
(setq my-org-agenda-linux-path "~/Nextcloud/org/")
;; Definicja ścieżek do pliku todo.org
(setq my-todo-file-windows "C:/Users/TwojaNazwaUżytkownika/Documents/org/todo.org")
(setq my-todo-file-linux "~/Nextcloud/todo/todo.org")
(setq my-todo-file-windows "C:/Users/paluc/Nextcloud/org/todo.org")
(setq my-todo-file-linux "~/Nextcloud/org/todo.org")
(setq my-note-file-windows "C:/Users/paluc/Nextcloud/org/other.org")
(setq my-note-file-linux "~/Nextcloud/org/other.org")
;; Funkcja ustawiająca odpowiednią ścieżkę na podstawie systemu
(defun my-set-org-agenda-files ()
@ -109,13 +306,26 @@ Missing packages are automatically installed."
(defun my-open-todo-file ()
"Otwórz plik todo.org w zależności od systemu operacyjnego."
(interactive)
(let ((todo-file (if (eq system-type 'windows-nt)
(let ((note-file (if (eq system-type 'windows-nt)
my-todo-file-windows
my-todo-file-linux)))
(if (file-exists-p note-file)
(find-file note-file)
(message "Plik todo.org nie istnieje: %s" note-file))))
(defun my-open-note-file ()
"Otwórz plik todo.org w zależności od systemu operacyjnego."
(interactive)
(let ((todo-file (if (eq system-type 'windows-nt)
my-note-file-windows
my-note-file-linux)))
(if (file-exists-p todo-file)
(find-file todo-file)
(message "Plik todo.org nie istnieje: %s" todo-file))))
;; Włącz org-mode automatycznie dla plików .org
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
@ -177,6 +387,7 @@ Missing packages are automatically installed."
(setq lsp-pylsp-plugins-pyflakes-enabled nil) ;; Wyłącz pyflakes
(setq lsp-diagnostics-provider :none) ;; Wyłącz diagnostykę LSP na rzecz Flycheck
(setq lsp-pylsp-plugins-ruff-enabled t) ;; Użyj flake8 zamiast pyflakes
;; Ścieżka do interpretera Python
@ -201,13 +412,15 @@ Missing packages are automatically installed."
;; ;; ----------------------------
(use-package flycheck
:ensure t
:hook (lsp-mode . flycheck-mode)
:hook ((lsp-mode . flycheck-mode) ;; Włącz Flycheck w trybie LSP
(emacs-lisp-mode . flycheck-mode)) ;; Włącz Flycheck w trybie Emacs Lisp
: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)
@ -238,37 +451,185 @@ Missing packages are automatically installed."
;; Obsługa wirtualnych środowisk Python (pyvenv)
;; ----------------------------
;; ;; 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)
;; ;; (use-package pyvenv
;; ;; :ensure t
;; ;; :config
;; ;; (defun my-auto-activate-venv ()
;; ;; "Automatycznie aktywuj venv zależnie od systemu operacyjnego."
;; ;; (let ((venv-path
;; ;; (cond
;; ;; ((eq system-type 'gnu/linux) "/home/pali112/venv")
;; ;; ((eq system-type 'windows-nt) "C:/Users/paluc/OneDrive/Dokumenty/venv"))))
;; ;; (when (and venv-path (file-directory-p venv-path))
;; ;; (pyvenv-activate venv-path)
;; ;; (setq lsp-pyright-python-executable-cmd
;; ;; (expand-file-name
;; ;; (if (eq system-type 'windows-nt)
;; ;; "Scripts/python.exe"
;; ;; "bin/python")
;; ;; venv-path)))))
;; ;; (add-hook 'python-mode-hook #'my-auto-activate-venv))
;; (use-package pyvenv
;; :ensure t
;; :config
;; (defun my-auto-activate-venv ()
;; "Automatycznie aktywuj venv zależnie od systemu operacyjnego."
;; (let ((venv-path
;; (cond
;; ((eq system-type 'gnu/linux) "/home/pali112/venv")
;; ((eq system-type 'windows-nt) "C:/Users/paluc/OneDrive/Dokumenty/venv"))))
;; (when (and venv-path (file-directory-p venv-path))
;; (pyvenv-activate venv-path)
;; (setq lsp-pyright-python-executable-cmd
;; (expand-file-name
;; (if (eq system-type 'windows-nt)
;; "Scripts/python.exe"
;; "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))))))
;; ----------------------------------
;; Obsługa venv z automatyczną aktywacją (Linux / Windows)
;; ----------------------------------
(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)
"Automatycznie aktywuj venv zależnie od systemu operacyjnego."
(let ((venv-path
(cond
((eq system-type 'gnu/linux) "/home/pali112/venv")
((eq system-type 'windows-nt) "C:/Users/paluc/OneDrive/Dokumenty/venv"))))
(when (and venv-path (file-directory-p venv-path))
(pyvenv-activate venv-path)
(setq lsp-pyright-python-executable-cmd
(expand-file-name
(if (eq system-type 'windows-nt)
"Scripts/python.exe"
"bin/python")
venv-path)))))
(add-hook 'python-mode-hook #'my-auto-activate-venv))
;; ----------------------------
;; Kolorowe oznaczenie trybu EVIL w modeline
;; ----------------------------
(defface evil-normal-tag
'((t (:background "#87D7FF" :foreground "black" :weight bold)))
"Styl dla NORMAL state.")
(defface evil-insert-tag
'((t (:background "#87FF5F" :foreground "black" :weight bold)))
"Styl dla INSERT state.")
(defface evil-replace-tag
'((t (:background "#FF5F5F" :foreground "black" :weight bold)))
"Styl dla REPLACE state.")
(defvar evil-mode-line-tag ""
"Zmienna przechowująca kolorowy tag trybu evil.")
(defun update-evil-mode-line-tag ()
"Aktualizuje kolorowy tag trybu evil w modeline."
(setq evil-mode-line-tag
(cond
((evil-normal-state-p)
(propertize " NORMAL " 'face 'evil-normal-tag))
((evil-insert-state-p)
(propertize " INSERT " 'face 'evil-insert-tag))
((evil-replace-state-p)
(propertize " REPLACE " 'face 'evil-replace-tag))
(t "")))
(force-mode-line-update))
(add-hook 'post-command-hook #'update-evil-mode-line-tag)
;; ----------------------------
;; Pokazywanie aktywnego VENV
;; ----------------------------
(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" :weight bold))
(propertize " No venv" 'face '(:foreground "gray"))))
;; ----------------------------
;; Finalny pasek mode-line
;; ----------------------------
(setq-default mode-line-format
(list
;; TRYB EVIL
'(:eval evil-mode-line-tag)
" "
;; NAZWA BUFORA
'mode-line-buffer-identification
" "
;; LINIA:KOLUMNA
"%l:%c "
;; PROGRESS W PLIKU
"%p "
;; TRYBY (np. Python, LSP itp.)
'mode-line-modes
" "
;; VENV
'(:eval (my-get-current-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)
;; (add-hook 'pyvenv-post-activate-hooks #'my-update-pyvenv-modeline)
;; (add-hook 'pyvenv-post-deactivate-hooks #'my-update-pyvenv-modeline)
;; ----------------------------
;; System podpowiedzi: Company
;; ----------------------------
@ -317,11 +678,13 @@ Missing packages are automatically installed."
;; ----------------------------
;; Konfiguracja Evil i lidera (leader key)
;; turbo
;; ----------------------------
(use-package evil
:ensure t
:config
(evil-mode 1))
(evil-ex-define-cmd "hs" 'split-window-below)
(use-package evil-leader
:ensure t
@ -331,12 +694,21 @@ Missing packages are automatically installed."
(evil-leader/set-key
"g g" 'magit-status
"o o" 'my-open-todo-file
"o n" 'my-open-note-file
"o t" 'org-toggle-inline-imageS
"o f" 'org-overview
"o c" 'org-insert-link
"o l" 'org-agenda-list
"o i" 'org-clock-in
"o s" 'org-clock-out
"o r" 'org-clock-report
"r i" 'org-roam-node-insert
"g a" 'magit-remote-add
"g p" 'magit-pull
"g i" 'magit-init
"g n" 'remote-nadpisz
"m b" 'build123d
"m v" 'vosk-start
"f f" 'find-file
"b l" 'ibuffer
"b w" 'buffer-menu-open
@ -350,7 +722,7 @@ Missing packages are automatically installed."
"l n" 'display-line-numbers-mode
"j s" 'jupyter-run-server-repl
"j a" 'jupyter-repl-associate-buffer
"s e" 'eshell
"s r" 'query-replace
"e l" 'flycheck-list-errors
"n n" 'narrow-to-region
"n w" 'widen
@ -368,11 +740,13 @@ Missing packages are automatically installed."
"<SPC> n" "Narrow"
"<SPC> f" "Files"
"<SPC> b" "Buffers"
"<SPC> r" "Roam"
"<SPC> t" "Treemacs"
"<SPC> l" "Lines"
"<SPC> j" "Jupyter"
"<SPC> s" "Shell"
"<SPC> s" "Search&Replace"
"<SPC> o" "Org"
"<SPC> m" "Macro"
)
@ -404,15 +778,28 @@ Missing packages are automatically installed."
;; ----------------------------
;; 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)
(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)
;; ----------------------------
@ -425,6 +812,8 @@ Missing packages are automatically installed."
(setq blacken-line-length 88))
;; ----------------------------
;; Podsumowanie i test
;; ----------------------------
@ -435,15 +824,26 @@ Missing packages are automatically installed."
;; ----------------------------
;; Other keys
;; ----------------------------
(global-set-key (kbd "C-c e") 'eshell)
(global-set-key (kbd "C-c s e") 'eshell)
(global-set-key (kbd "C-c d") 'flycheck-list-errors)
(global-set-key (kbd "C-c o f") 'save-image-from-clipboard) ;; Zapisz zdjęcie
(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 SPC o o \n"
"m v" 'vosk-start
(setq initial-scratch-message (concat ";; Aby otworzyć org todo daj na SPC o o \n"
";; Aby otworzyć org notatki daj na SPC o n \n"
";; Aby przesuwać nagłówki w Org dajsz shift + j lub l \n"
";; Aby odpalić VOSK daj na SPC m v \n"
";; Aby otworzyć eshell daj na C-c s e \n"
";; Otwarcie menu attachment C-c C-a \n"
";; Otwarcie załącznika attachment C-c C-a o \n"
";; Zapisanie zdjęcia w org C-c o f \n"
";; Dodanie linku SPC o c \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"
@ -460,8 +860,10 @@ Missing packages are automatically installed."
;; 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
'("d5fd482fcb0fe42e849caba275a01d4925e422963d1cd165565b31d3f4189c87" "09b833239444ac3230f591e35e3c28a4d78f1556b107bafe0eb32b5977204d93" default))
'(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)))
'(org-roam 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.
@ -472,29 +874,125 @@ Missing packages are automatically installed."
;; ----------------------------
;; ibuffer
;; ----------------------------
(with-eval-after-load 'ibuffer
(evil-set-initial-state 'ibuffer-mode 'normal)
(evil-define-key 'normal ibuffer-mode-map
(kbd "j") 'ibuffer-forward-line
(kbd "k") 'ibuffer-backward-line
(kbd "dd") 'ibuffer-do-kill-lines
(kbd "x") 'ibuffer-do-kill-on-deletion-marks
(kbd "v") 'ibuffer-mark-forward
(kbd "u") 'ibuffer-unmark-forward
(kbd "gg") 'beginning-of-buffer
(kbd "G") 'end-of-buffer
(kbd "/") 'ibuffer-do-isearch
(kbd "q") 'quit-window))
;; ----------------------------
;; Moje makra
;; ----------------------------
(defun build123d ()
(defun vosk-start ()
"Start Vosk script in the appropriate environment."
(interactive)
(let ((file-path (if (eq system-type 'windows-nt)
"C:/Users/paluc/OneDrive/Dokumenty/venv/voskpl.py"
"~/vosk/voskpl.py")))
;; Przejdź do voskpl.py
(find-file file-path)
;; Otwórz eshell i uruchom vosk
(eshell 100)
(insert (format "python %s" file-path))
(eshell-send-input)))
(defun build123d ()
"Automatyzacja workflow: uruchomienie Jupyter Lab, OCP VSCode i konfiguracja REPL."
(interactive)
;; Przejdź do pliku simrig.py
(find-file "~/Dokumenty/simrig2/simrig.py") ;; Zmień na poprawną ścieżkę do pliku
;; Otwórz eshell 1 i uruchom Jupyter Lab
(eshell 1)
(insert "jupyter lab")
(eshell-send-input)
;; Przejdź do eshell 2 i uruchom Python -m ocp_vscode
(eshell 2)
(insert "python -m ocp_vscode")
(eshell-send-input)
;; Powróć do pliku simrig.py
(find-file "~/Dokumenty/simrig2/simrig.py")
;; Uruchom jupyter-run-server-repl i pozwól użytkownikowi potwierdzić wartości interaktywnie
(call-interactively 'jupyter-run-server-repl)
;; Powróć do pliku simrig.py
(find-file "~/Dokumenty/simrig2/simrig.py")
;; Przypisz bufor do Jupyter REPL
(call-interactively 'jupyter-repl-associate-buffer))
(let ((file-path (if (eq system-type 'windows-nt)
;; "C:/Users/paluc/OneDrive/Dokumenty/simrig2/simrig.py"
"C:/Users/paluc/OneDrive/Dokumenty/frezarka/frezarka.py"
;; "C:/Users/paluc/OneDrive/Dokumenty/uchwytBaterii/uchwyt.py"
;; "/home/pali112/Dokumenty/simrig2/simrig.py"
;; "/home/pali112/Dokumenty/Uchwyt_Myszki/uchwyt.py"
;; "/home/pali112/Dokumenty/Box_Adriana/box.py"
"/home/pali112/Dokumenty/Box_Adriana_Arduino/box.py"
;; "/home/pali112/Dokumenty/uchwyt_baterii/uchwyt.py"
)))
(find-file file-path)
;; Otwórz eshell 1 i uruchom Jupyter Lab
(eshell 1)
(sleep-for 1) ;; Czekaj na aktywację pipenv shell
(insert "jupyter lab")
(eshell-send-input)
(sleep-for 3) ;; Czekaj na aktywację pipenv shell
;; Przejdź do eshell 2 i uruchom Python -m ocp_vscode
(eshell 2)
(sleep-for 1) ;; Czekaj na aktywację pipenv shell
(insert "python -m ocp_vscode")
(eshell-send-input)
(sleep-for 1) ;; Czekaj na aktywację pipenv shell
;; Powróć do pliku simrig.py
(find-file file-path)
;; Uruchom jupyter-run-server-repl i pozwól użytkownikowi potwierdzić wartości interaktywnie
(call-interactively 'jupyter-run-server-repl)
(sleep-for 1) ;; Czekaj na aktywację pipenv shell
(find-file file-path)
(call-interactively 'jupyter-repl-associate-buffer)
;; Otwórz stronę w przeglądarce
(browse-url "http://localhost:3939/viewer")))
(defun remote-nadpisz ()
"Fetch changes from remote, reset local branch, and clean untracked files."
(interactive)
(let ((eshell-buffer (generate-new-buffer "*eshell*")))
(with-current-buffer eshell-buffer
(eshell-mode)
(goto-char (point-max))
(insert "git fetch --all && git reset --hard origin/master && git clean -fd")
(eshell-send-input) ;; Wykonuje komendę
(insert "exit")
(eshell-send-input))
(switch-to-buffer eshell-buffer))) ;; Przełącza się do nowego
;; Funkcja tworząca pusty plik .gitignore w Emacs
(defun create-gitignore (directory)
"Tworzy pusty plik .gitignore w podanym katalogu DIRECTORY."
(interactive "DChoose directory: ")
(let ((gitignore-path (expand-file-name ".gitignore" directory)))
(if (file-exists-p gitignore-path)
(message "Plik .gitignore już istnieje w katalogu %s" directory)
(with-temp-file gitignore-path
(insert ""))
(message "Pusty plik .gitignore został utworzony w katalogu %s" directory))))
;; Aby użyć tej funkcji, wpisz M-x create-gitignore i wskaż katalog, w którym ma być utworzony pusty plik.
(setq select-enable-clipboard t)
(with-eval-after-load 'evil
(define-key evil-insert-state-map (kbd "C-v") 'yank))

217
init.el~
View File

@ -1,145 +1,13 @@
;; ----------------------------
;; Podstawowa konfiguracja pakietów i MELPA
;; ----------------------------
(require 'package)
;; Dodaj repozytoria
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("org" . "https://orgmode.org/elpa/")))
;; Inicjalizuj system pakietów
("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
;; Odśwież listę pakietów, jeśli jest pusta
(unless package-archive-contents
(package-refresh-contents))
;; Funkcja do instalowania pakietów
(defun ensure-package-installed (&rest packages)
"Ensure that the given PACKAGES are installed.
Missing packages are automatically installed."
(dolist (package packages)
(unless (package-installed-p package)
(package-install package))))
;; Instalacja wymaganych pakietów
(ensure-package-installed
'use-package
'magit
'blacken
'lsp-mode
'lsp-ui
'flycheck
'company
'jupyter
'treemacs
'winum
'lsp-treemacs)
;; Wczytaj i skonfiguruj `use-package`
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
;; Przełączanie się między oknami
(use-package winum
:ensure t
:config
(winum-mode))
;; ----------------------------
;; Konfiguracja org-mode
;; ----------------------------
;; Definicja ścieżek dla Windows i Linux
(setq my-org-agenda-windows-path "C:/Users/TwojaNazwaUżytkownika/Documents/org/")
(setq my-org-agenda-linux-path "~/Nextcloud/todo/")
;; Definicja ścieżek do pliku todo.org
(setq my-todo-file-windows "C:/Users/TwojaNazwaUżytkownika/Documents/org/todo.org")
(setq my-todo-file-linux "~/Nextcloud/todo/todo.org")
;; Funkcja ustawiająca odpowiednią ścieżkę na podstawie systemu
(defun my-set-org-agenda-files ()
"Ustaw pliki agendy Org w zależności od systemu operacyjnego."
(setq org-agenda-files
(directory-files-recursively
(if (eq system-type 'windows-nt)
my-org-agenda-windows-path
my-org-agenda-linux-path)
"\\.org$")))
;; Wywołaj funkcję przy starcie Emacs
(my-set-org-agenda-files)
;; Funkcja otwierająca plik todo.org
(defun my-open-todo-file ()
"Otwórz plik todo.org w zależności od systemu operacyjnego."
(interactive)
(let ((todo-file (if (eq system-type 'windows-nt)
my-todo-file-windows
my-todo-file-linux)))
(if (file-exists-p todo-file)
(find-file todo-file)
(message "Plik todo.org nie istnieje: %s" todo-file))))
;; Włącz org-mode automatycznie dla plików .org
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
;; Włącz folding w org-mode (skróty klawiszowe)
(setq org-startup-folded t) ;; Start with folded headlines
(setq org-hide-leading-stars t) ;; Ukrywanie gwiazdek poza pierwszym poziomem
(setq org-ellipsis "") ;; Znak na końcu zwiniętych sekcji
;; Ustawienia klawisza TAB w org-mode przy użyciu Evil
(add-hook 'org-mode-hook
(lambda ()
(evil-define-key 'normal org-mode-map (kbd "TAB") 'org-cycle)
(evil-define-key 'normal org-mode-map (kbd "S-TAB") 'org-shifttab)))
;; Podświetlanie składni i elementów w org-mode
(setq org-fontify-whole-heading-line t) ;; Podświetlaj cały nagłówek
(setq org-fontify-done-headline t) ;; Podświetlaj ukończone nagłówki
(setq org-fontify-quote-and-verse-blocks t) ;; Podświetlaj bloki cytatów i wierszy
;; Automatyczne podświetlanie kodu w blokach źródłowych
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
;; Wsparcie dla hierarchicznego folding w org-mode
(setq org-cycle-separator-lines 2) ;; Próg zwijania między sekcjami
;; Wygląd i czytelność w org-mode
(setq org-hide-emphasis-markers t) ;; Ukryj znaki formatowania (*bold*, /italic/)
(setq org-pretty-entities t) ;; Wyświetl symbole matematyczne jako unicode
(setq org-highlight-latex-and-related '(latex script entities)) ;; Podświetlaj LaTeX
;; Współpraca z tytułami i nagłówkami
(setq org-startup-indented t) ;; Włącz automatyczne wcięcia
(setq org-indent-mode-turns-on-hiding-stars t) ;; Ukryj gwiazdki w nagłówkach
;; Funkcje dodatkowe
(setq org-log-done 'time) ;; Zapisuj czas oznaczenia zadania jako DONE
(setq org-return-follows-link t) ;; ENTER podąża za linkami
;; ----------------------------
;; Instalacja i konfiguracja LSP dla Python
;; ----------------------------
@ -155,12 +23,14 @@ Missing packages are automatically installed."
(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-diagnostics-provider :none) ;; Wyłącz diagnostykę LSP na rzecz Flycheck
(setq lsp-pylsp-plugins-flake8-enabled nil) ;; Użyj flake8 zamiast pyflakes
(setq lsp-pylsp-plugins-ruff-enabled t) ;; Użyj flake8 zamiast pyflakes
(setq lsp-pylsp-plugins-flake8-ignore ["F405" "F403" "E231" "E303" "E302" "E305" "E501" "D100"]) ;; Ignorowanie błędów w flake8
;; Ścieżka do interpretera Python
;; Ignorowanie błędów w pylint
(setq lsp-pylsp-plugins-pylint-args [
"--disable=wrong-import-order,missing-module-docstring,invalid-name"
])
(setq lsp-pyright-python-executable-cmd "python3"))
@ -196,14 +66,8 @@ Missing packages are automatically installed."
(defun set-flycheck-executables ()
"Set Flycheck executables to use from the active Python virtual environment."
(when (and (boundp 'pyvenv-virtual-env) pyvenv-virtual-env)
(let* ((flake8-path (concat pyvenv-virtual-env
(if (eq system-type 'windows-nt)
"/Scripts/flake8.exe" ; Ścieżka na Windows
"/bin/flake8"))) ; Ścieżka na Linux/Mac
(pylint-path (concat pyvenv-virtual-env
(if (eq system-type 'windows-nt)
"/Scripts/pylint.exe" ; Ścieżka na Windows
"/bin/pylint")))) ; Ścieżka na Linux/Mac
(let ((flake8-path (concat pyvenv-virtual-env "/Scripts/flake8.exe")) ; Ścieżka na Windows
(pylint-path (concat pyvenv-virtual-env "/Scripts/pylint.exe"))) ; Ścieżka na Windows
(when (file-executable-p flake8-path)
(flycheck-set-checker-executable 'python-flake8 flake8-path))
(when (file-executable-p pylint-path)
@ -309,66 +173,15 @@ Missing packages are automatically installed."
(evil-leader/set-leader "<SPC>")
(evil-leader/set-key
"g g" 'magit-status
"o o" 'my-open-todo-file
"o l" 'org-agenda-list
"o i" 'org-clock-in
"o s" 'org-clock-out
"o r" 'org-clock-report
"g a" 'magit-remote-add
"f f" 'find-file
"b b" 'switch-to-buffer
"b m" 'buffer-menu
"b w" 'buffer-menu-open
"t t" 'treemacs
"t a" 'treemacs-add-project-to-workspace
"t r" 'treemacs-remove-project-from-workspace
"t c" 'treemacs-copy-file
"t f" 'treemacs-create-file
"t m" 'treemacs-rename-file
"l l" 'toggle-truncate-lines
"l n" 'display-line-numbers-mode
"j s" 'jupyter-run-server-repl
"j a" 'jupyter-repl-associate-buffer
"e e" 'eshell
"n n" 'narrow-to-region
"n w" 'widen
"a" 'mark-whole-buffer
"TAB" (lambda () (interactive) (switch-to-buffer (other-buffer)))
"1" 'winum-select-window-1
"2" 'winum-select-window-2
"3" 'winum-select-window-3
"4" 'winum-select-window-4
"5" 'winum-select-window-5))
(which-key-add-key-based-replacements
"<SPC> g" "Magit"
"<SPC> n" "Narrow"
"<SPC> f" "Files"
"<SPC> b" "Buffers"
"<SPC> t" "Treemacs"
"<SPC> l" "Lines"
"<SPC> j" "Jupyter"
"<SPC> e" "Eshell"
"<SPC> o" "Org"
)
;; Utwórz mapę klawiszy dla "SPC"
(define-prefix-command 'my-space-prefix)
(define-key evil-normal-state-map (kbd "SPC") 'my-space-prefix)
;; Dodaj mapowanie "SPC 0" do Treemacs
(define-key my-space-prefix (kbd "0") 'my-treemacs-select-or-open)
;; Funkcja, która przełącza się na okno Treemacs lub je otwiera
(defun my-treemacs-select-or-open ()
"Przełącz się na okno Treemacs lub otwórz Treemacs, jeśli nie jest aktywne."
(interactive)
(if (treemacs-get-local-window)
(treemacs-select-window)
(treemacs)))
))
@ -403,7 +216,7 @@ Missing packages are automatically installed."
:ensure t
:hook (python-mode . blacken-mode)
:config
(setq blacken-line-length 75))
(setq blacken-line-length 88))
;; ----------------------------
@ -417,19 +230,18 @@ Missing packages are automatically installed."
;; Other keys
;; ----------------------------
(global-set-key (kbd "C-c e") 'eshell)
(global-set-key (kbd "C-c d") 'flycheck-list-errors)
(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 SPC o o \n"
(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 flycheck C-c d \n"
";; Pokaż błędy flymake C-c d \n"
"\n"
";;Jupyter \n"
";;Wykonaj Połącz się z serwerem C-c j s \n"
@ -449,4 +261,3 @@ Missing packages are automatically installed."
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(put 'narrow-to-region 'disabled nil)

View File

@ -0,0 +1,145 @@
.# name: Python .gitignore
# key: pyignore
# --
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
Pipfile.lock
# poetry
poetry.lock
# pdm
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582
__pypackages__/
# Celery
celerybeat-schedule
celerybeat.pid
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre
.pyre/
# pytype
.pytype/
# Cython debug symbols
cython_debug/
# Ruff
.ruff_cache/
# PyPI configuration file
.pypirc

View File

@ -2,4 +2,5 @@
# name: Location Vector
# key: locv
# --
Location(Vector(0,0,0),(0,0,0))
with Locations(Location(Vector(${1:0}, ${2:0}, ${3:0}), (${4:0}, ${5:0}, ${6:0}))):
${0:#wypełnij}