From 16571c0f2225c135ace108ff0c4759d2f2c6acdd Mon Sep 17 00:00:00 2001 From: urec56 Date: Mon, 17 Feb 2025 13:23:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=BA=D1=82=D1=83=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BB=20=D0=BC=D0=B5=D0=B9?= =?UTF-8?q?=D0=BD=20=D0=BE=D1=82=20=D0=B1=D1=83=D0=BB=D0=B8=D0=B2=D0=B5?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 6 +- flake.nix | 1 + modules/home-manager/gui/vscode.nix | 12 +- modules/home-manager/terminal/zsh.nix | 17 ++- modules/home-manager/wm/bspwm/bspwm.nix | 1 - modules/nixos/hardware.nix | 16 ++- modules/nixos/virtualisation.nix | 2 +- modules/nixos/xserver.nix | 15 ++- nixos/home.nix | 1 - nixos/packages.nix | 58 ++++++++- nvim/README.md | 150 +++++++++++++--------- nvim/ftplugin/nix.lua | 4 + nvim/init.lua | 11 +- nvim/lazy-lock.json | 3 +- nvim/lua/custom/plugins/golang.lua | 10 +- nvim/lua/kickstart/plugins/autoformat.lua | 17 ++- nvim/lua/kickstart/plugins/lsp.lua | 37 ++++-- nvim/lua/kickstart/plugins/telescope.lua | 2 +- nvim/lua/kickstart/plugins/themes.lua | 63 ++++++++- nvim/lua/kickstart/plugins/treesitter.lua | 53 ++++---- nvim/lua/kickstart/plugins/vim-sleuth.lua | 5 - nvim/lua/kickstart/settings.lua | 26 +++- 22 files changed, 360 insertions(+), 150 deletions(-) create mode 100644 nvim/ftplugin/nix.lua delete mode 100644 nvim/lua/kickstart/plugins/vim-sleuth.lua diff --git a/flake.lock b/flake.lock index 0093d60..d8aaf1f 100644 --- a/flake.lock +++ b/flake.lock @@ -263,11 +263,11 @@ }, "nixpkgs2": { "locked": { - "lastModified": 1736344531, - "narHash": "sha256-8YVQ9ZbSfuUk2bUf2KRj60NRraLPKPS0Q4QFTbc+c2c=", + "lastModified": 1737885589, + "narHash": "sha256-Zf0hSrtzaM1DEz8//+Xs51k/wdSajticVrATqDrfQjg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "bffc22eb12172e6db3c5dde9e3e5628f8e3e7912", + "rev": "852ff1d9e153d8875a83602e03fdef8a63f0ecf8", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 4a8ad9c..334f561 100644 --- a/flake.nix +++ b/flake.nix @@ -33,6 +33,7 @@ # pkgs = nixpkgs.legacyPackages.${system}; config = { allowUnfree = true; + rocmSupport = true; permittedInsecurePackages = [ "python-2.7.18.8" "electron-25.9.0" diff --git a/modules/home-manager/gui/vscode.nix b/modules/home-manager/gui/vscode.nix index 719359b..ffee404 100644 --- a/modules/home-manager/gui/vscode.nix +++ b/modules/home-manager/gui/vscode.nix @@ -32,12 +32,12 @@ version = "1.3.1"; sha256 = "f5da7cfe02c06fc3899e6b0b55b380280619e7085abcf5b6024f9684ba846c99"; } - { # https://marketplace.visualstudio.com/items?itemName=dlasagno.rasi - name = "rasi"; - publisher = "dlasagno"; - version = "1.0.0"; - sha256 = "b3ad1a95e8f770d01b489c6c4652111364216baa00b2670e05b5a8aa9fb0e9f9"; - } + # { # https://marketplace.visualstudio.com/items?itemName=dlasagno.rasi + # name = "rasi"; + # publisher = "dlasagno"; + # version = "1.0.0"; + # sha256 = "b3ad1a95e8f770d01b489c6c4652111364216baa00b2670e05b5a8aa9fb0e9f9"; + # } # { # https://marketplace.visualstudio.com/items?itemName=a-h.templ # name = "templ"; # publisher = "a-h"; diff --git a/modules/home-manager/terminal/zsh.nix b/modules/home-manager/terminal/zsh.nix index e189929..1655629 100644 --- a/modules/home-manager/terminal/zsh.nix +++ b/modules/home-manager/terminal/zsh.nix @@ -52,16 +52,25 @@ }; # Environment variables that will be set for zsh session. - sessionVariables = { - HISTORY_SUBSTRING_SEARCH_FUZZY = "не работает блять"; # Нечёткий поиск для стрелок вверх/вниз. - }; + # sessionVariables = { + # }; # Extra commands that should be added to .zshrc initExtra = '' source ${pkgs.zsh-you-should-use}/share/zsh/plugins/you-should-use/you-should-use.plugin.zsh ''; - historySubstringSearch.enable = true; # Чтоб вверх/вниз учитывал уже написанную команду + historySubstringSearch = { + enable = true; # Чтоб вверх/вниз учитывал уже написанную команду + searchUpKey = [ + "^[[A" + "$terminfo[kcuu1]" + ]; + searchDownKey = [ + "^[[B" + "$terminfo[kcud1]" + ]; + }; oh-my-zsh = { # https://github.com/ohmyzsh/ohmyzsh enable = true; diff --git a/modules/home-manager/wm/bspwm/bspwm.nix b/modules/home-manager/wm/bspwm/bspwm.nix index 38d1356..a82523a 100644 --- a/modules/home-manager/wm/bspwm/bspwm.nix +++ b/modules/home-manager/wm/bspwm/bspwm.nix @@ -35,7 +35,6 @@ "librewolf" ]; - monitors = let workspaces = [ "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"]; in { diff --git a/modules/nixos/hardware.nix b/modules/nixos/hardware.nix index 703a0ab..ad27518 100644 --- a/modules/nixos/hardware.nix +++ b/modules/nixos/hardware.nix @@ -4,7 +4,7 @@ { pkgs, ... }: { hardware = { # Параметры для 24.05 и unstable могут сильно отличаться amdgpu = { - opencl.enable = true; # # Enable OpenCL support using ROCM runtime library. + opencl.enable = true; # Enable OpenCL support using ROCM runtime library. # amdvlk = { # Гавно лаганое, лучше radv юзать (radeon vulkan) # enable = true; # Enable AMDVLK Vulkan driver. # support32Bit.enable = true; # Enable 32-bit driver support. @@ -18,6 +18,7 @@ enable32Bit = true; # install 32-bit drivers for 32-bit applications (such as Wine). extraPackages = with pkgs; [ libva # VAAPI (Video Acceleration API) + rocmPackages.clr.icd # OpenCL ]; }; @@ -46,9 +47,20 @@ # HIP # Most software has the HIP libraries hard-coded. You can work around it on NixOS by using: - # systemd.tmpfiles.rules = [ + # systemd.tmpfiles.rules = [ # Legacy # "L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}" # ]; + systemd.tmpfiles.rules = let + rocmEnv = pkgs.symlinkJoin { + name = "rocm-combined"; + paths = with pkgs.rocmPackages; [ + rocblas + hipblas + clr + ]; + }; in [ + "L+ /opt/rocm - - - - ${rocmEnv}" + ]; boot.initrd.kernelModules = [ "amdgpu" ]; # Мб не обязательно diff --git a/modules/nixos/virtualisation.nix b/modules/nixos/virtualisation.nix index c525628..0edee91 100644 --- a/modules/nixos/virtualisation.nix +++ b/modules/nixos/virtualisation.nix @@ -11,7 +11,7 @@ }; }; - # spiceUSBRedirection.enable = true; # Connect USB devices to libvirt VMs, both local and remote. + spiceUSBRedirection.enable = true; # Connect USB devices to libvirt VMs, both local and remote. libvirtd = { # https://nixos.wiki/wiki/Libvirt enable = true; qemu.package = pkgs.qemu_full; diff --git a/modules/nixos/xserver.nix b/modules/nixos/xserver.nix index c30bbd1..01a04a9 100644 --- a/modules/nixos/xserver.nix +++ b/modules/nixos/xserver.nix @@ -1,8 +1,3 @@ -# Не совсем понял как менять тему в sddm. Но мне оно не надо. Оставлю ссылки -# https://www.reddit.com/r/NixOS/comments/14sb6s2/sddm_themes_finally_did_a_dumb_workaround/ -# https://www.reddit.com/r/NixOS/comments/14dlvbr/sddm_theme/ - - { pkgs, ... }: { services.displayManager = { @@ -36,6 +31,16 @@ i3.enable = true; # i3-gaps доступен в стоке в новых версиях }; + # Fully disable DPMS and screen blanking + config = '' + Section "Extensions" + Option "DPMS" "false" + EndSection + Section "ServerFlags" + Option "BlankTime" "0" + EndSection + ''; + xkb = { layout = "us,ru"; variant = ""; diff --git a/nixos/home.nix b/nixos/home.nix index 8296237..80eb53b 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -51,7 +51,6 @@ targets = { vscode.enable = false; # Руками ставлю. Не нравится stylix вариант firefox.enable = false; # Руками ставлю и бекаплю каталог браузера - # lightdm.enable = false; # Не хочу обои в lightdm (в сурсе есть настройка, но не билдит, мать ебал) }; # iconTheme = { # enable = true; diff --git a/nixos/packages.nix b/nixos/packages.nix index 14a47fe..df329e3 100644 --- a/nixos/packages.nix +++ b/nixos/packages.nix @@ -46,6 +46,35 @@ # greenclip.enable = true; # https://github.com/erebe/greenclip (использую clipmenu вместо этого) # fstrim.enable = true; # Чистит ssd для норм производительности. Пока не пользуюсь # archisteamfarm = {}; # Фарм карточек стима афк. Простро раскомментить мало, надо настроить + ollama = let + pinPackage = + { + name, + commit, + sha256, + }: + (import (builtins.fetchTarball { + inherit sha256; + url = "https://github.com/NixOS/nixpkgs/archive/${commit}.tar.gz"; + }) { system = pkgs.system; }).${name}; + in { + enable = true; + acceleration = "rocm"; + # Ollama Port 11434/tcp + host = "0.0.0.0"; + port = 11434; + openFirewall = true; + # pin ollama v0.5.7 until nixpkgs update + # https://github.com/NixOS/nixpkgs/issues/375359 + package = (pinPackage { + name = "ollama"; + commit = "d0169965cf1ce1cd68e50a63eabff7c8b8959743"; + sha256 = "sha256:1hh0p0p42yqrm69kqlxwzx30m7i7xqw9m8f224i3bm6wsj4dxm05"; + }); + rocmOverrideGfx = "10.3.0"; + # additional environment variables + # environmentVariables = { HSA_OVERRIDE_GFX_VERSION="10.3.0"; }; + }; }; programs = { @@ -184,11 +213,20 @@ tailwindcss-language-server # Tailwind LSP # tailwindcss + # Protobuf + # protols # LSP + buf # LSP + protobuf + protoc-gen-go + protoc-gen-go-grpc + # Other hugo # Для моего блога yaml-language-server # YAML LSP taplo # TOML LSP vim-language-server # VimScript LSP + go-migrate # Database migrations. CLI and Golang library + postman # API Development Environment # For nvim tree-sitter # For nvim @@ -235,9 +273,12 @@ # zscroll # A text scroller for use with panels and shells https://github.com/noctuid/zscroll tokei # Количество строк кода на разных языках в каталоге pass # Менеджер паролей в терминале + amdgpu_top # Tool to display AMD GPU usage btop # Монитор ресурсов в терминале rocmPackages.rocm-smi # Чтоб в btop было gpu (не работает) - # rocmPackages_5.rocm-smi # Старая версия пакета выше. Хз какой надо + rocmPackages.rocblas # Для работы hip? + rocmPackages.hipblas # Для работы hip? + rocmPackages.clr # Для работы hip? pkgs2.yt-dlp # Скачивать и смотреть медиа с разных сайтов tasktimer # TUI task timer. Можно несколько таймеров с описанием запустить. В терминал tt timer # A "sleep" with progress. Таймер на пельмени "timer 5m" @@ -253,6 +294,7 @@ lm_sensors # Сенсоры httpie # interacting with APIs & HTTP servers jq # Cli JSON processor + miller # Like awk, sed, cut, join, and sort for data formats such as CSV, TSV, JSON, JSON Lines, and positionally-indexed # htmlq # Как jq, но для html. Извлекать конкретные элементы из html # mkvtoolnix-cli # Cross-platform tools for Matroska @@ -385,8 +427,7 @@ steam-run # На всякий случай mangohud # Фпс и нагрузку на пк показывает в играх gamemode # Оптимизации линуха и игр - wineWowPackages.stable # support both 32- and 64-bit applications - wineWowPackages.stableFull + wineWowPackages.stableFull # support both 32- and 64-bit applications # wineWowPackages.staging # Можно назвать бета версией вайна winetricks # winetricks (all versions) # wineWowPackages.waylandFull # native wayland support (unstable) @@ -414,10 +455,13 @@ ## IDE ## ######### - neovim # Мб не надо писать, он у меня необычный, через nixvim flake - # vscode # Надо в home.packages писать, чтоб расширения ставились без рута - jetbrains-toolbox # Надо в home.packages писать. https://nixos.wiki/wiki/Jetbrains_Tools - helix # A Kakoune / Neovim inspired editor, written in Rust. + neovim + # helix # A Kakoune/Neovim inspired editor, written in Rust. + + # Закинул в home.nix + # vscode + # jetbrains-toolbox + # zed-editor ########### ## Icons ## diff --git a/nvim/README.md b/nvim/README.md index 6041836..d5e2ec7 100644 --- a/nvim/README.md +++ b/nvim/README.md @@ -47,6 +47,27 @@ ln -s ~/nixos-private-dots/nvim ~/.config/nvim Чтоб понять есть ли проблемы с конфигом, может какие-то пакеты отсутствуют, можно запустить `:healthcheck`. +## Изменить в будущем + +Сейчас я сделал в стоке везде табуляцию в 4 символа на таб. Не пробелы. Если захочу это исправить и сделать per language настройки, то это можно сделать по разному. Сейчас у меня lsp/formatter сами заменяют табы на пробелы при сохранении файла. + +Use `:h ftplugin` together with `:h :setlocal` +В каталоге nvim надо сделать каталог `ftplugin` и в него добавлять файлы `filetype.lua`. Например для python будет `python.lua`. И там можно писать настройки для каждого отдельного языка: +```lua +vim.bo.tabstop = 4 -- size of a hard tabstop (ts). +vim.bo.shiftwidth = 4 -- size of an indentation (sw). +vim.bo.expandtab = true -- always uses spaces instead of tab characters (et). +vim.bo.softtabstop = 4 -- number of spaces a counts for. When 0, feature is off (sts) +``` + +Если не хочется возиться с тонной файлов, то можно добавить это в init.vim (надо переписать для init.lua): +```vim +autocmd BufEnter *.py :setlocal tabstop=4 shiftwidth=4 expandtab +autocmd BufEnter *.js :setlocal tabstop=2 shiftwidth=2 expandtab +``` + +Per project можно использовать `.editorconfig` файл в корне проекта. Нвим должен работать с его настройками. + ## Бинды Тут будет список биндов, которых нет в стандартном NeoVim @@ -57,70 +78,74 @@ ln -s ~/nixos-private-dots/nvim ~/.config/nvim Я не помню откуда эти бинды, может они есть в стоке, а может нет, но они полезные. -| Bind | Description | -| -------------- | ---------------------------------- | -| `K` | Hover documentation | -| `ctrl+o` | Go back | -| `ctrl+i` | Go forward (if you went backwards) | -| `p` | Paste from nvim register | -| `ctrl+shift+v` | Paste from system clipboard | -| `y` | Yank(copy) to nvim register | -| `space y` | Yank(copy) to system clipboard | -| `d` | Delete(copy) to nvim register | -| `space d` | Delete(copy) to system clipboard | -| `alt + up/down/j/k` | Move lines in visual mode | -| `[d` | Go to previous `D`iagnostic message | -| `]d` | Go to next `D`iagnostic message | -| `space e` | Show diagnostic `E`rror message | -| `space q` | Open diagnostic `Q`uickfix | +| Bind | Description | +|---------------------|---------------------------------------------------------| +| `K` | Hover documentation | +| `ctrl+o` | Go back | +| `ctrl+i` | Go forward (if you went backwards) | +| `p` | Paste from nvim register | +| `ctrl+shift+v` | Paste from system clipboard | +| `y` | Yank(copy) to nvim register | +| `space y` | Yank(copy) to system clipboard | +| `d` | Delete(copy) to nvim register | +| `space d` | Delete(copy) to system clipboard | +| `alt + up/down/j/k` | Move lines in visual mode | +| `[d` | Go to previous `D`iagnostic message | +| `]d` | Go to next `D`iagnostic message | +| `space e` | Show diagnostic `E`rror message | +| `space q` | Open diagnostic `Q`uickfix | +| `ctrl+l` | Перейти к следующему плейсхолдеру сниппета в insert mod | Бинды в таблице ниже нажимаются без пробела перед ними. Просто бинд -| Bind | Description | File | -| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -| `esc esc` | Exit terminal mode (This won't work in all terminal emulators/tmux/etc. Try your own mapping or use `` to exit terminal mode) | settings.lua | -| `esc` | Creal highlights on search when pressing Esc in normal mode | settings.lua | -| `gp` | `G`oto context (`p`arent) | treesitter.lua | -| `gd` | `G`oto `D`efinition | lsp.lua | -| `gr` | `G`oto `R`eferences | lsp.lua | -| `gI` | `G`oto `I`mplementation | lsp.lua | -| `gD` | `G`oto `D`eclaration. This is not Goto Definition, this is Goto Declaration. For example, in C this would take you to the header | lsp.lua | -| `gc` | Toggle Comment from mini-comment plugin | - | -| `\` | Toggle file tree | file-tree.lua | +| Bind | Description | File | +|-----------|----------------------------------------------------------------------------------------------------------------------------------|----------------| +| `esc esc` | Exit terminal mode (Or use `` to exit terminal mode) | settings.lua | +| `esc` | Creal highlights on search when pressing Esc in normal mode | settings.lua | +| `gp` | `G`oto context (`p`arent) | treesitter.lua | +| `gd` | `G`oto `D`efinition | lsp.lua | +| `gr` | `G`oto `R`eferences | lsp.lua | +| `gI` | `G`oto `I`mplementation | lsp.lua | +| `gD` | `G`oto `D`eclaration. This is not Goto Definition, this is Goto Declaration. For example, in C this would take you to the header | lsp.lua | +| `gc` | Toggle Comment from mini-comment plugin | - | +| `\` | Toggle file tree | file-tree.lua | Перед каждым из биндов в нижней таблице надо нажать `leader`, что есть `space`, пробел. -| Bind | Description | File | -| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -| `tt` | `T`oggle `T`erminal | terminal.lua | -| `gta` | `G`o `T`ag `A`dd. Add json tags for struct | golang.lua | -| `gtr` | `G`o `T`ag `R`emove. Remove json tags for struct | golang.lua | -| `gfs` | `G`o `F`ill `S`truct | golang.lua | -| `gfc` | `G`o `F`ill Switch `C`ase | golang.lua | -| `gie` | `G`o `I`f `E`rr | golang.lua | -| `gfp` | `G`o `F`ix `P`lurals | golang.lua | -| `D` | Type `D`efinition. Jump to the typo of the word under your cursor. Useful when you're not sure what type a variable is and you want to see the definition of its *type*, not where it was *defined*. | lsp.lua | -| `ds` | `D`ocument `S`ymbols. Fuzzy find all the symbols in your current document. Symbols are things like variables, funckions, types, etc. | lsp.lua | -| `ws` | `W`orkspace `S`ymbols. Fuzzy find all the symbols in your currend workspace. Similar to document symbols, except searches over you entire project | lsp.lua | -| `rn` | `R`e`n`ame. Rename the variable under your cursor. Most Language Servers support renaming across files, etc. | lsp.lua | -| `ca` | `C`ode `A`ction. Execute a code action, usually your cursor needs to be on top of an error or a suggestion from your LSP for this to activate | lsp.lua | -| `sh` | `S`earch `H`elp | health.lua | -| `sk` | `S`earch `K`eymaps | health.lua | -| `sf` | `S`earch `F`iles | health.lua | -| `ss` | `S`earch `S`elect Telescope | health.lua | -| `sw` | `S`earch current `W`ord | health.lua | -| `sg` | `S`earch by `G`rep | health.lua | -| `sd` | `S`earch `D`iagnostics | health.lua | -| `sr` | `S`earch `R`esume | health.lua | -| `s.` | `S`earch Recent Files ("." for repeat) | health.lua | -| `space` | Find existing buffers. Аналог перелючения между вкладками | health.lua | -| `/` | Fuzzily search in current buffer | health.lua | -| `s/` | `S`earch `/` in Open Files. Live Grep in Open Files | health.lua | -| `sn` | `S`earch `N`eovim files. Shortcut for searching your Neovim configuration files | health.lua | -| `st` | `S`earch `T`hemes | health.lua | -| `q` | Open diagnostic `Q`uicfix list | settings.lua | -| `f` | `F`ormat buffer | autoformat.lua | +| Bind | Description | File | +|---------|---------------------------------------------------------------------------------------------------------------------------------------------------|----------------| +| `tt` | `T`oggle `T`erminal | terminal.lua | +| `gta` | `G`o `T`ag `A`dd. Add json tags for struct | golang.lua | +| `gtr` | `G`o `T`ag `R`emove. Remove json tags for struct | golang.lua | +| `gs` | `G`o fill `S`truct | golang.lua | +| `gc` | `G`o fill Switch `C`ase | golang.lua | +| `gp` | `G`o fix `P`lurals (change func foo(b int, a int, r int) -> func foo(b, a, r int)) | golang.lua | +| `ge` | `G`o if `E`rr | golang.lua | +| `gi` | `G`o `I`mports | golang.lua | +| `D` | Type `D`efinition. Jump to the typo of the word under your cursor. | lsp.lua | +| | Useful when you're not sure what type a variable is and you want to see the definition of its *type*, not where it was *defined*. | | +| `ds` | `D`ocument `S`ymbols. Fuzzy find all the symbols in your current document. Symbols are things like variables, funckions, types, etc. | lsp.lua | +| `ws` | `W`orkspace `S`ymbols. Fuzzy find all the symbols in your currend workspace. Similar to document symbols, except searches over you entire project | lsp.lua | +| `rn` | `R`e`n`ame. Rename the variable under your cursor. Most Language Servers support renaming across files, etc. | lsp.lua | +| `ca` | `C`ode `A`ction. Execute a code action, usually your cursor needs to be on top of an error or a suggestion from your LSP for this to activate | lsp.lua | +| `ss` | `S`earch Document `S`ymbols | lsp.lua | +| `sS` | `S`earch `S`elect Telescope | health.lua | +| `sh` | `S`earch `H`elp | health.lua | +| `sk` | `S`earch `K`eymaps | health.lua | +| `sf` | `S`earch `F`iles | health.lua | +| `sw` | `S`earch current `W`ord | health.lua | +| `sg` | `S`earch by `G`rep | health.lua | +| `sd` | `S`earch `D`iagnostics | health.lua | +| `sr` | `S`earch `R`esume | health.lua | +| `s.` | `S`earch Recent Files ("." for repeat) | health.lua | +| `space` | Find existing buffers. Аналог перелючения между вкладками | health.lua | +| `/` | Fuzzily search in current buffer | health.lua | +| `s/` | `S`earch `/` in Open Files. Live Grep in Open Files | health.lua | +| `sn` | `S`earch `N`eovim files. Shortcut for searching your Neovim configuration files | health.lua | +| `st` | `S`earch `T`hemes | health.lua | +| `q` | Open diagnostic `Q`uicfix list | settings.lua | +| `f` | `F`ormat buffer | autoformat.lua | ### Git @@ -130,19 +155,19 @@ ln -s ~/nixos-private-dots/nvim ~/.config/nvim Без пробела | Bind | Description | File | -| ---- | ----------------------------- | ------------ | +|------|-------------------------------|--------------| | `]c` | Jump to next git `C`hange | gitsigns.lua | | `[c` | Jump to previous git `C`hange | gitsigns.lua | Visual mode. С пробелом | Bind | Description | File | -| ---- | ---------------- | ------------ | +|------|------------------|--------------| | `hs` | `S`tage git hunk | gitsigns.lua | | `hr` | `R`eset git hunk | gitsigns.lua | Normal mode. С пробелом | Bind | Description | File | -| ---- | ------------------------------ | ------------ | +|------|--------------------------------|--------------| | `hs` | Git `S`tage hunk | gitsigns.lua | | `hr` | Git `R`eset hunk | gitsigns.lua | | `hS` | Git `S`tage buffer | gitsigns.lua | @@ -159,7 +184,7 @@ Normal mode. С пробелом Без пробела | Bind | Description | File | -| ---- | ------------------------------ | --------- | +|------|--------------------------------|-----------| | `F5` | Debug: Start/Continue | debug.lua | | `F1` | Debug: Step Into | debug.lua | | `F2` | Debug: Step Over | debug.lua | @@ -168,7 +193,7 @@ Normal mode. С пробелом С пробелом | Bind | Description | File | -| ---- | -------------------------- | --------- | +|------|----------------------------|-----------| | `b` | Debug: Toggle `B`reakpoint | debug.lua | | `B` | Debug: Set `B`reakpoint | debug.lua | @@ -190,6 +215,7 @@ Normal mode. С пробелом - `YAML LSP` имеет [опциональные настройки](https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.txt#yamlls) - `JSON LSP` имеет [опциональные настройки](https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.txt#jsonls) - `rust-analyzer` имеет много опциональных настроек +- Чтоб `sql` работал внутри `.go` файлов, sql запросы надо писать внутри \`` так `\`. Тоесть внутри \` с пробелом в начале и конце, а не просто строка. - `sqlfluff` требует иметь `.sqlfluff` в директории проекта. Вот пример конфига: ```toml [sqlfluff] diff --git a/nvim/ftplugin/nix.lua b/nvim/ftplugin/nix.lua new file mode 100644 index 0000000..55de27d --- /dev/null +++ b/nvim/ftplugin/nix.lua @@ -0,0 +1,4 @@ +vim.bo.expandtab = true +vim.bo.tabstop = 2 +vim.bo.shiftwidth = 2 +vim.bo.softtabstop = 2 diff --git a/nvim/init.lua b/nvim/init.lua index 4f6c7f9..bab56e1 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -32,9 +32,6 @@ require('lazy').setup({ -- Установлены из коробки в kickstart.nvim -- --------------------------------------------- - -- Detect expandtab and shiftwidth automatically - require 'kickstart.plugins.vim-sleuth', - -- Git integration for buffers require 'kickstart.plugins.gitsigns', @@ -96,6 +93,14 @@ require('lazy').setup({ -- Plugins for git require 'custom.plugins.git', + -- Autoformat markdown tables + { + 'Kicamon/markdown-table-mode.nvim', + config = function() + require('markdown-table-mode').setup() + end, + }, + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 0336ef5..a93642c 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -14,6 +14,7 @@ "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, "go.nvim": { "branch": "master", "commit": "c6d5ca26377d01c4de1f7bff1cd62c8b43baa6bc" }, "gruvbox-material": { "branch": "master", "commit": "e41451337d33997aff4c078a83165a9f66e2d38d" }, + "gruvbox.nvim": { "branch": "main", "commit": "68c3460a5d1d1a362318960035c9f3466d5011f5" }, "guihua.lua": { "branch": "master", "commit": "d783191eaa75215beae0c80319fcce5e6b3beeda" }, "image.nvim": { "branch": "master", "commit": "f1163cc2f6fff5b0de7c23c7502eee0df23a3e0e" }, "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, @@ -21,6 +22,7 @@ "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, "lazydev.nvim": { "branch": "main", "commit": "8620f82ee3f59ff2187647167b6b47387a13a018" }, "luvit-meta": { "branch": "main", "commit": "55709f183b0742a7e4f47688c284f81148ad4dc0" }, + "markdown-table-mode.nvim": { "branch": "main", "commit": "870d0449c1c78c673faa9637a63036f9537b4caa" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "97d9f1d3ad205dece6bcafd1d71cf1507608f3c7" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, @@ -51,6 +53,5 @@ "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "tokyonight.nvim": { "branch": "main", "commit": "7bb270adaa7692c2c33befc35f5567fc596a2504" }, - "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, "which-key.nvim": { "branch": "main", "commit": "1f8d414f61e0b05958c342df9b6a4c89ce268766" } } diff --git a/nvim/lua/custom/plugins/golang.lua b/nvim/lua/custom/plugins/golang.lua index 9edbb6b..686e44c 100644 --- a/nvim/lua/custom/plugins/golang.lua +++ b/nvim/lua/custom/plugins/golang.lua @@ -12,10 +12,12 @@ return { require('go').setup() vim.keymap.set({ 'n' }, 'gta', ':GoAddTag', { desc = '[G]o [T]ag [A]dd' }) vim.keymap.set({ 'n' }, 'gtr', ':GoRmTag', { desc = '[G]o [T]ag [R]emove' }) - vim.keymap.set({ 'n' }, 'gfs', ':GoFillStruct', { desc = '[G]o [F]ill [S]truct' }) - vim.keymap.set({ 'n' }, 'gfc', ':GoFillSwitch', { desc = '[G]o [F]ill Switch [C]ase' }) - vim.keymap.set({ 'n' }, 'gie', ':GoIfErr', { desc = '[G]o [I]f [E]rr' }) - vim.keymap.set({ 'n' }, 'gfp', ':GoFixPlurals', { desc = '[G]o [F]ix [P]lurals' }) + vim.keymap.set({ 'n' }, 'gs', ':GoFillStruct', { desc = '[G]o fill [S]truct' }) + vim.keymap.set({ 'n' }, 'gc', ':GoFillSwitch', { desc = '[G]o fill Switch [C]ase' }) + -- Go Fix Plurals - change func foo(b int, a int, r int) -> func foo(b, a, r int) + vim.keymap.set({ 'n' }, 'gp', ':GoFixPlurals', { desc = '[G]o fix [P]lurals' }) + vim.keymap.set({ 'n' }, 'ge', ':GoIfErr', { desc = '[G]o if [E]rr' }) + vim.keymap.set({ 'n' }, 'gi', ':GoImports', { desc = '[G]o [I]mports' }) end, event = { 'CmdlineEnter' }, ft = { 'go', 'gomod' }, diff --git a/nvim/lua/kickstart/plugins/autoformat.lua b/nvim/lua/kickstart/plugins/autoformat.lua index 4de5c4a..8ce5e72 100644 --- a/nvim/lua/kickstart/plugins/autoformat.lua +++ b/nvim/lua/kickstart/plugins/autoformat.lua @@ -40,9 +40,9 @@ return { end, formatters_by_ft = { lua = { 'stylua' }, + go = { 'gofmt', 'injected' }, sql = { 'sqlfluff' }, - -- sql = { 'sql_formatter' }, - -- ["*"] = { "injected" }, -- enables injected-lang formatting for all filetypes + -- ['*'] = { 'injected' }, -- enables injected-lang formatting for all filetypes -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, @@ -67,8 +67,19 @@ return { -- end, -- stdin = true, -- }, + sqlfluff = { + command = 'sqlfluff', + args = { + 'format', + -- 'fix', + -- '--dialect', + -- 'postgres', + -- '--disable-progress-bar', + '-', + }, + stdin = true, + }, }, }, }, } - diff --git a/nvim/lua/kickstart/plugins/lsp.lua b/nvim/lua/kickstart/plugins/lsp.lua index 695c852..b009452 100644 --- a/nvim/lua/kickstart/plugins/lsp.lua +++ b/nvim/lua/kickstart/plugins/lsp.lua @@ -93,7 +93,7 @@ return { -- Fuzzy find all the symbols in your current document. -- Symbols are things like variables, functions, types, etc. -- Было ds [D]ocument [S]ymbols - map('S', require('telescope.builtin').lsp_document_symbols, 'Document [S]ymbols') + map('ss', require('telescope.builtin').lsp_document_symbols, 'Document [S]ymbols') -- Fuzzy find all the symbols in your current workspace. -- Similar to document symbols, except searches over your entire project. @@ -190,8 +190,28 @@ return { -- taplo } + -- local util = require 'lspconfig.util' local lspconfig = require 'lspconfig' + -- require('lspconfig.configs').postgres_lsp = { + -- default_config = { + -- name = 'postgres_lsp', + -- cmd = { 'postgres_lsp' }, + -- filetypes = { 'sql' }, + -- single_file_support = true, + -- root_dir = util.root_pattern 'root-file.txt', + -- }, + -- } + + -- SQL + -- lspconfig.postgres_lsp.setup { force_setup = true } + lspconfig.sqls.setup { + on_attach = function(client) + -- Выключить форматирование + client.server_capabilities.documentFormattingProvider = false + end, + } + -- Nix lspconfig.nixd.setup {} @@ -199,15 +219,6 @@ return { lspconfig.gopls.setup {} lspconfig.templ.setup {} - -- SQL - -- lspconfig.postgres_lsp.setup {} - lspconfig.sqls.setup { - on_attach = function(client, bufnr) - -- Выключить форматирование - client.server_capabilities.documentFormattingProvider = false - end, - } - -- Frontend lspconfig.tailwindcss.setup {} lspconfig.ts_ls.setup {} @@ -254,7 +265,9 @@ return { -- }; -- } -- } - lspconfig.clangd.setup {} + lspconfig.clangd.setup { + filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' }, -- Удалил "proto" + } lspconfig.cmake.setup {} -- Python @@ -282,6 +295,8 @@ return { lspconfig.taplo.setup {} lspconfig.vimls.setup {} lspconfig.yamlls.setup {} + -- lspconfig.protols.setup {} + lspconfig.buf_ls.setup {} -- Ensure the servers and tools above are installed -- To check the current status of installed tools and/or manually install diff --git a/nvim/lua/kickstart/plugins/telescope.lua b/nvim/lua/kickstart/plugins/telescope.lua index c6bf852..6acc98b 100644 --- a/nvim/lua/kickstart/plugins/telescope.lua +++ b/nvim/lua/kickstart/plugins/telescope.lua @@ -84,7 +84,7 @@ return { vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sS', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) diff --git a/nvim/lua/kickstart/plugins/themes.lua b/nvim/lua/kickstart/plugins/themes.lua index d54772c..486365a 100644 --- a/nvim/lua/kickstart/plugins/themes.lua +++ b/nvim/lua/kickstart/plugins/themes.lua @@ -95,6 +95,60 @@ return { -- Гандоны не дают выбрать тему нормально -- -- Приходится конфиг переписывать ради выбора расцветок -- ---------------------------------------------------------- + { + 'ellisonleao/gruvbox.nvim', + priority = 1000, + config = true, + -- opts = ... + init = function() + local colors = require('gruvbox').palette + colors.neutral_aqua = '#8bba7f' + colors.bright_red = '#f2594b' + colors.bright_green = '#a4ab43' + -- Default options: + require('gruvbox').setup { + terminal_colors = true, -- add neovim terminal colors + undercurl = true, -- underline errors + underline = true, -- underline links + bold = false, -- bold keywords + italic = { + strings = true, + emphasis = true, -- курсив выделения + comments = true, + operators = false, + folds = true, -- курсив для сворачиваемых блоков кода + }, + strikethrough = true, -- зачёркиваниe удалённых или устаревших элементов + invert_selection = false, + invert_signs = false, + invert_tabline = false, + invert_intend_guides = false, + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = '', -- can be "hard", "soft" or empty string + palette_overrides = {}, + overrides = { + LspReferenceText = { -- ссылки на элементы под курсором + bg = '#504945', + }, + LspReferenceWrite = { + bg = '#504945', + }, + LspReferenceRead = { + bg = '#504945', + }, + String = { + fg = colors.neutral_aqua, + }, + ['@keyword.import.go'] = { + fg = colors.bright_red, + }, + }, + dim_inactive = false, + transparent_mode = false, + } + vim.cmd.colorscheme 'gruvbox' + end, + }, { 'sainnhe/gruvbox-material', priority = 1000, @@ -105,11 +159,15 @@ return { vim.g.gruvbox_material_foreground = 'mix' -- 'grey', 'colored', 'highlighted' vim.g.gruvbox_material_diagnostic_virtual_text = 'colored' - vim.g.gruvbox_material_better_performance = 1 vim.g.gruvbox_material_diagnostic_line_highlight = 1 vim.g.gruvbox_material_diagnostic_text_highlight = 1 + + -- vim.g.gruvbox_material_inlay_hints_background = 'dimmed' + -- vim.g.gruvbox_material_better_performance = 1 + -- vim.g.gruvbox_material_spell_foreground = 'colored' + -- vim.g.gruvbox_material_enable_bold = 1 -- vim.g.gruvbox_material_enable_italic = true - vim.cmd.colorscheme 'gruvbox-material' + -- vim.cmd.colorscheme 'gruvbox-material' end, }, { @@ -147,4 +205,3 @@ return { end, }, } - diff --git a/nvim/lua/kickstart/plugins/treesitter.lua b/nvim/lua/kickstart/plugins/treesitter.lua index ef3464d..0c80789 100644 --- a/nvim/lua/kickstart/plugins/treesitter.lua +++ b/nvim/lua/kickstart/plugins/treesitter.lua @@ -3,6 +3,34 @@ return { { 'nvim-treesitter/nvim-treesitter', + dependencies = { + { + 'nvim-treesitter/nvim-treesitter-context', + config = function() + require('treesitter-context').setup { + enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + multiwindow = false, -- Enable multiwindow support. + max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + line_numbers = true, + multiline_threshold = 3, -- Maximum number of lines to show for a single context + trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' + -- Separator between context and content. Should be a single character string, like '-'. + -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. + separator = nil, + zindex = 20, -- The Z-index of the context window + on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching + } + vim.keymap.set('n', 'gp', function() + require('treesitter-context').go_to_context(vim.v.count1) + end, { silent = true, desc = '[G]oto context ([P]arent)' }) + end, + }, + -- { + -- 'nvim-treesitter/nvim-treesitter-textobjects', + -- }, + }, build = ':TSUpdate', main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` @@ -34,6 +62,7 @@ return { 'toml', 'yaml', 'cmake', + 'printf', }, -- Autoinstall languages that are not installed auto_install = true, @@ -53,28 +82,4 @@ return { -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }, - { - 'nvim-treesitter/nvim-treesitter-context', - dependencies = { 'nvim-treesitter/nvim-treesitter' }, - config = function() - require('treesitter-context').setup { - enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) - multiwindow = false, -- Enable multiwindow support. - max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. - min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. - line_numbers = true, - multiline_threshold = 3, -- Maximum number of lines to show for a single context - trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' - mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' - -- Separator between context and content. Should be a single character string, like '-'. - -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. - separator = nil, - zindex = 20, -- The Z-index of the context window - on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching - } - vim.keymap.set('n', 'gp', function() - require('treesitter-context').go_to_context(vim.v.count1) - end, { silent = true, desc = '[G]oto context ([P]arent)' }) - end, - }, } diff --git a/nvim/lua/kickstart/plugins/vim-sleuth.lua b/nvim/lua/kickstart/plugins/vim-sleuth.lua deleted file mode 100644 index d882bcd..0000000 --- a/nvim/lua/kickstart/plugins/vim-sleuth.lua +++ /dev/null @@ -1,5 +0,0 @@ --- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). -return { - 'tpope/vim-sleuth', -- Detect expandtab and shiftwidth automatically -} - diff --git a/nvim/lua/kickstart/settings.lua b/nvim/lua/kickstart/settings.lua index 96736e0..c988d41 100644 --- a/nvim/lua/kickstart/settings.lua +++ b/nvim/lua/kickstart/settings.lua @@ -19,7 +19,24 @@ vim.opt.relativenumber = true -- Табуляция в 4 символа vim.opt.tabstop = 4 --- vim.opt.shiftwidth = 4 +vim.opt.shiftwidth = 4 +vim.opt.softtabstop = 4 +-- Юзать пробелы вместо табов +vim.opt.expandtab = true + +-- yaml lsp за меня решают сколько пробелов мне надо. Это фикс +-- Их параметры конфига для переназначения не работают. Пришлось костыль сделать +vim.cmd [[ + autocmd FileType yaml setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab +]] + +-- Комментировать .proto код биндом +vim.api.nvim_create_autocmd('FileType', { + pattern = 'proto', + callback = function() + vim.bo.commentstring = '// %s' + end, +}) -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -27,6 +44,9 @@ vim.opt.mouse = 'a' -- Don't show the mode, since it's already in the status line vim.opt.showmode = false +-- greatest remap ever +vim.keymap.set('x', 'p', '"_dP', { desc = '[P]aste' }) + -- Sync clipboard between OS and Neovim. -- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. @@ -39,8 +59,8 @@ vim.opt.showmode = false vim.keymap.set('n', 'y', '"+y', { desc = '[Y]ank to system clipboard' }) vim.keymap.set('v', 'y', '"+y', { desc = '[Y]ank to system clipboard' }) -- vim.keymap.set('n', 'Y', '"+Y', { desc = '[Y]ank to system clipboard' }) -vim.keymap.set('n', 'd', '"_d', { desc = '[D]elete to system clipboard' }) -vim.keymap.set('v', 'd', '"_d', { desc = '[D]elete to system clipboard' }) +vim.keymap.set('n', 'd', '"+d', { desc = '[D]elete to system clipboard' }) +vim.keymap.set('v', 'd', '"+d', { desc = '[D]elete to system clipboard' }) -- Change `K` hover documentation size vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {