From 5180874b1915d2a2f7888c678b0b887a696b2099 Mon Sep 17 00:00:00 2001 From: Daniil Shvalov Date: Sun, 10 Mar 2024 16:30:38 +0300 Subject: [PATCH] feat(emacs): sync config --- .arcconfig | 6 +- .config/emacs/.lsp-session-v1 | 1 + .config/emacs/config.el | 28 +++-- .config/nvim/lazy-lock.json | 35 +++--- .config/nvim/lua/plugins/init.lua | 190 +++++++++++++++++------------- 5 files changed, 153 insertions(+), 107 deletions(-) create mode 100644 .config/emacs/.lsp-session-v1 diff --git a/.arcconfig b/.arcconfig index 57c8455..d3c821e 100644 --- a/.arcconfig +++ b/.arcconfig @@ -1,7 +1,7 @@ [core] - # editor = "nvim" - # pager = "nvim -R" - pager = "(f=$(mktemp --suffix .diff); cat > $f; my-emacs $f; rm -v $f)" + editor = "nvim" + pager = "nvim -R" + # pager = "(f=$(mktemp --suffix .diff); cat > $f; my-emacs $f; rm -v $f)" [alias] st = status diff --git a/.config/emacs/.lsp-session-v1 b/.config/emacs/.lsp-session-v1 new file mode 100644 index 0000000..969c8c8 --- /dev/null +++ b/.config/emacs/.lsp-session-v1 @@ -0,0 +1 @@ +#s(lsp-session ("/home/danilshvalov/arcadia/taxi/backend-py3/services/dashboards/test_dashboards/cron") nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ())) \ No newline at end of file diff --git a/.config/emacs/config.el b/.config/emacs/config.el index 0168cda..f67580c 100644 --- a/.config/emacs/config.el +++ b/.config/emacs/config.el @@ -83,7 +83,7 @@ (defun my-set-current-directory (directory) ;; (setq my-directory directory) - (add-to-list 'my-directories (cons (my-tab-name-current) directory)) + (setq my-directories (push (cons (my-tab-name-current) directory) my-directories)) ) ;; remove image resize delay @@ -220,7 +220,7 @@ (doom-themes-set-faces 'user `(highlight :foreground 'unspecified - :background 'unspecified + :background "#3C435E" :inherit 'region) `(font-lock-comment-face :foreground ,(doom-lighten 'comments 0.2)) `(corfu-current :background ,(doom-color 'region)) @@ -504,7 +504,10 @@ expand immediately. Common gateway for :keymaps 'override "s" 'avy-goto-char-2)) -(use-builtin eglot +(use-package jsonrpc) +(use-package eldoc) + +(use-package eglot :custom (eglot-sync-connect nil) (eglot-events-buffer-size 0) @@ -512,7 +515,7 @@ expand immediately. Common gateway for ((LaTeX-mode c++-ts-mode csharp-mode - ;; python-ts-mode + python-ts-mode conf-toml-mode tsx-ts-mode) . @@ -533,7 +536,7 @@ expand immediately. Common gateway for (add-to-list 'eglot-server-programs '(c++-ts-mode . ("clangd" "--compile-commands-dir=build_debug"))) (add-to-list 'eglot-server-programs '(latex-mode . ("texlab"))) - ;; (add-to-list 'eglot-server-programs '(python-ts-mode . ("pylsp"))) + (add-to-list 'eglot-server-programs '(python-ts-mode . ("pylsp"))) (add-to-list 'eglot-server-programs '(conf-toml-mode . ("taplo" "lsp" "stdio")))) @@ -575,6 +578,10 @@ expand immediately. Common gateway for ;; "rg --null --line-buffered --color=never --max-columns=1000 --path-separator / --smart-case --no-heading --with-filename --line-number --search-zip") (consult-async-split-style 'semicolon) (consult-preview-key nil) + (consult-async-min-input 0) + (consult-async-refresh-delay 0) + (consult-async-input-debounce 0) + (consult-async-input-throttle 0) :general (nvmap :keymaps 'override @@ -1118,7 +1125,7 @@ Quit if no candidate is selected." (nvmap "ga" 'ialign)) -(use-builtin flymake +(use-package flymake :hook ((sql-mode) . flymake-mode) :commands flymake-mode :custom @@ -1128,7 +1135,7 @@ Quit if no candidate is selected." (flymake-no-changes-timeout 1.0) (flymake-start-on-save-buffer t) (flymake-proc-compilation-prevents-syntax-check t) - (flymake-show-diagnostics-at-end-of-line nil) + (flymake-show-diagnostics-at-end-of-line t) (flymake-wrap-around nil) :general (nvmap @@ -2039,6 +2046,13 @@ Note that these rules can't contain anchored rules themselves." (let* ((branches (or branches (arc--select-branch-list)))) (apply 'arc--call-process "arc" "branch" "--delete" branches))) +(use-package indent-bars + :elpaca (indent-bars :host github :repo "jdtsmith/indent-bars") + :custom + (indent-bars-color-by-depth nil) + (indent-bars-color '(shadow :face-bg nil :blend 0.5)) + :hook ((prog-mode text-mode) . indent-bars-mode)) + (advice-add 'arc--call-process :around #'execute-at-project-root) (modify-syntax-entry ?_ "w") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 66dc5ab..68d24fa 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,10 +1,10 @@ { "LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" }, "arrow.nvim": { "branch": "master", "commit": "9d98760d9a195174a24b6ccc20217bc98f3596e0" }, - "ccc.nvim": { "branch": "main", "commit": "0ca30a4fd8429bffb6394f4ee27166fb4ff29fbf" }, + "ccc.nvim": { "branch": "main", "commit": "ec6e23fd2c0bf4ffcf71c1271acdcee6e2c6f49c" }, "cmdbuf.nvim": { "branch": "main", "commit": "aa3a26fa7f9b77f5d9de89fa662eebd09d8885de" }, "conform.nvim": { "branch": "master", "commit": "192a6d2ddace343f1840a8f72efe2315bd392243" }, - "fzf-lua": { "branch": "main", "commit": "3b3cc17c7bb91f6bbef7166c0756f89a189c4db4" }, + "fzf-lua": { "branch": "main", "commit": "91ec17b4fd0d810599f054eef08db967a0457fbf" }, "git-conflict.nvim": { "branch": "main", "commit": "4c8e252b87d54d944c1e56bfb477f78b6fdaf661" }, "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, "indent-o-matic": { "branch": "master", "commit": "4d11e98f523d3c4500b1dc33f0d1a248a4f69719" }, @@ -12,28 +12,27 @@ "keymap.nvim": { "branch": "main", "commit": "825e0c1c141c278ed6754086115165330f5cb045" }, "langmapper.nvim": { "branch": "main", "commit": "9d98285b2e45d1c392c6a03e7adedde97d2aa71a" }, "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, - "leap.nvim": { "branch": "main", "commit": "b41f48643b483bb0881c0f7804f6f0be7bb95155" }, - "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, + "leap.nvim": { "branch": "main", "commit": "52f7ce4fcc1764caac77cf4d43c2c4f5fb42d517" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, "luautf8": { "branch": "master", "commit": "bdd3d7fb6ef22334fde028ba792d3a16309a4de8" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "21d33d69a81f6351e5a5f49078b2e4f0075c8e73" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "fe4cce44dec93c69be17dad79b21de867dde118a" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "1212fb6082b7177dde17ea65e429e027835aeb40" }, - "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, - "mini.nvim": { "branch": "main", "commit": "b7403ad0c2a4dab777244171ca1b7e8c89696584" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "mini.nvim": { "branch": "main", "commit": "1d49300d50a2c8ee7faecceb151084f207ff65ba" }, "mkdnflow.nvim": { "branch": "main", "commit": "1b24b8b5fe10fe09af4572c0165293e0dcd998aa" }, - "neodev.nvim": { "branch": "main", "commit": "3157f2e876fd6223d36cfa76bee4709247d62fa5" }, + "neodev.nvim": { "branch": "main", "commit": "de3685b8c1cd439dd96b7958793f6f381f98652d" }, "nvim-FeMaco.lua": { "branch": "main", "commit": "6af458f0196215f397db31a6e1fb2df795811693" }, - "nvim-autopairs": { "branch": "master", "commit": "c6139ca0d5ad7af129ea6c89cb4c56093f2c034a" }, - "nvim-jdtls": { "branch": "master", "commit": "382b9f625861f47d95876bcfb4c261f3b96077cb" }, - "nvim-lspconfig": { "branch": "master", "commit": "ec7d51a619049c7c597f469f81ea199db6794651" }, + "nvim-autopairs": { "branch": "master", "commit": "2e8a10c5fc0dcaf8296a5f1a7077efcd37065cc8" }, + "nvim-jdtls": { "branch": "master", "commit": "01b57f75b00e71541aa328398d5e10ba5ca3ea18" }, + "nvim-lspconfig": { "branch": "master", "commit": "d1bab4cf4b69e49d6058028fd933d8ef5e74e680" }, "nvim-surround": { "branch": "main", "commit": "8f2af76134f37058dc4c27a24bc5f86c9cae76dc" }, - "nvim-treesitter": { "branch": "master", "commit": "6e2b56cbe75ddf18e6efecee44bc3936d70b0b3e" }, + "nvim-treesitter": { "branch": "master", "commit": "eb1914bb10dc9b114a61197de0ec58a308c40071" }, "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, - "nvim-web-devicons": { "branch": "master", "commit": "0bb67ef952ea3eb7b1bac9c011281471d99a27bc" }, + "nvim-web-devicons": { "branch": "master", "commit": "7f30f2da3c3641841ceb0e2c150281f624445e8f" }, "nvim_rocks": { "branch": "master", "commit": "fd1f1dff8cc8ed5688fc4b890352a2a340940e34" }, - "obsidian.nvim": { "branch": "main", "commit": "9ede6c86b1f47afe00442a6e84fa1f5b00153742" }, - "oil.nvim": { "branch": "master", "commit": "132b4ea0740c417b9d717411cab4cf187e1fd095" }, - "peek.nvim": { "branch": "master", "commit": "c6ab252ff874e1597e27f865dcfc68b15cae0cff" }, - "plantuml-syntax": { "branch": "master", "commit": "309c15c77794433f276fb09eb4e3b8f381003cfd" }, + "oil.nvim": { "branch": "master", "commit": "bf753c3e3f8736939ad5597f92329dfe7b1df4f5" }, + "peek.nvim": { "branch": "master", "commit": "4163a48f190d2b2d94840be3eb38b4af83961ebe" }, + "plantuml-syntax": { "branch": "master", "commit": "845abb56dcd3f12afa6eb47684ef5ba3055802b8" }, "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, "suda.vim": { "branch": "master", "commit": "8b0fc3711760195aba104e2d190cff9af8267052" }, "term-edit.nvim": { "branch": "master", "commit": "e04f69d5828c6e6a4d81c34f75f18762fad50372" }, @@ -44,6 +43,6 @@ "vim-fswitch": { "branch": "master", "commit": "94acdd8bc92458d3bf7e6557df8d93b533564491" }, "vim-gnupg": { "branch": "main", "commit": "f9b608f29003dfde6450931dc0f495a912973a88" }, "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, - "vimtex": { "branch": "master", "commit": "01c4c167338b74dc0c30621841bc548b52e96330" }, + "vimtex": { "branch": "master", "commit": "9df79e15bf035d1cfb32c11fffed38dd7b6a0501" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } } \ No newline at end of file diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua index 179218b..8bd3205 100644 --- a/.config/nvim/lua/plugins/init.lua +++ b/.config/nvim/lua/plugins/init.lua @@ -52,9 +52,9 @@ return { map:set("", "2") map - :mode("nvo") - :set("H", "^", { desc = "Start of line" }) - :set("L", "$", { desc = "End of line" }) + :mode("nvo") + :set("H", "^", { desc = "Start of line" }) + :set("L", "$", { desc = "End of line" }) map:prefix("t", "+toggle"):set("w", function() if not vim.opt_local.formatoptions:get().a then @@ -65,25 +65,25 @@ return { end, { desc = "Toggle wrap" }) map - :new({ mode = "nv", expr = true }) - :set("k", "(v:count? 'k' : 'gk')") - :set("j", "(v:count? 'j' : 'gj')") + :new({ mode = "nv", expr = true }) + :set("k", "(v:count? 'k' : 'gk')") + :set("j", "(v:count? 'j' : 'gj')") map :prefix("f") :set(".", kit.wrap(vim.fn.system, "open ."), { desc = "Open in finder" }) map - :prefix("d", "+dir") - :set("c", function() - local path, _ = vim.fn.expand("%:p:h"):gsub("oil://", "") - vim.cmd.cd(path) - vim.notify("Directory: " .. vim.fn.expand("%:p:~:h"):gsub("oil://", "")) - end, { desc = "Set cwd to current file directory" }) - :set("y", function() - vim.fn.setreg("+", vim.fn.expand("%:p:h")) - vim.notify("Copied directory: " .. vim.fn.expand("%:p:~:h")) - end, { desc = "Yank cwd" }) + :prefix("d", "+dir") + :set("c", function() + local path, _ = vim.fn.expand("%:p:h"):gsub("oil://", "") + vim.cmd.cd(path) + vim.notify("Directory: " .. vim.fn.expand("%:p:~:h"):gsub("oil://", "")) + end, { desc = "Set cwd to current file directory" }) + :set("y", function() + vim.fn.setreg("+", vim.fn.expand("%:p:h")) + vim.notify("Copied directory: " .. vim.fn.expand("%:p:~:h")) + end, { desc = "Yank cwd" }) map:set("", vim.cmd.noh) end, @@ -256,18 +256,49 @@ return { config = function() local conform = require("conform") + local black + if vim.fn.executable("taxi-black") == 1 then + black = "taxi_format" + else + black = "black" + end + + local clang_format + if vim.fn.executable("taxi-format") == 1 then + clang_format = "taxi_format" + else + clang_format = "clang-format" + end + conform.setup({ + formatters = { + taxi_format = { + command = "taxi-format", + args = { + "--quiet", + "--force", + "$FILENAME", + "-", + }, + stdin = false, + } + }, formatters_by_ft = { lua = { "stylua" }, - python = { "black" }, + python = { black }, markdown = { "prettier" }, - cpp = { "clang-format" }, + cpp = { clang_format }, }, }) local function format_buffer() local bufnr = vim.api.nvim_get_current_buf() - conform.format({ async = true, bufnr = bufnr, timeout_ms = 5000 }, function(error) + conform.format({ + async = true, + bufnr = bufnr, + timeout_ms = 5000, + lsp_fallback = true, + }, function(error) if not error then vim.api.nvim_buf_call(bufnr, function() vim.cmd.write() @@ -432,7 +463,7 @@ return { path = 3, fmt = function(str) if - str == "[No Name]" or vim.tbl_contains({ "toggleterm", "fzf" }, vim.bo.filetype) + str == "[No Name]" or vim.tbl_contains({ "toggleterm", "fzf" }, vim.bo.filetype) then return "" end @@ -549,24 +580,24 @@ return { end map - :prefix("x") - :set("q", open("quickfix")) - :set("x", open("workspace_diagnostics"), { desc = "Show code errors" }) + :prefix("x") + :set("q", open("quickfix")) + :set("x", open("workspace_diagnostics"), { desc = "Show code errors" }) map - :new({ prefix = "c" }) - :set("r", vim.lsp.buf.rename) - :set("h", vim.diagnostic.open_float) - :set("a", vim.lsp.buf.code_action) + :new({ prefix = "c" }) + :set("r", vim.lsp.buf.rename) + :set("h", vim.diagnostic.open_float) + :set("a", vim.lsp.buf.code_action) map - :prefix("g", "+goto") - :set("d", open("lsp_definitions"), { desc = "Go definitions" }) - :set("D", vim.lsp.buf.declaration, { desc = "Go declaration" }) - :set("r", open("lsp_references"), { desc = "Go references" }) - :set("i", open("lsp_implementations"), { desc = "Go implementations" }) - :set("n", vim.diagnostic.goto_next, { desc = "Go next error" }) - :set("p", vim.diagnostic.goto_prev, { desc = "Go prev error" }) + :prefix("g", "+goto") + :set("d", open("lsp_definitions"), { desc = "Go definitions" }) + :set("D", vim.lsp.buf.declaration, { desc = "Go declaration" }) + :set("r", open("lsp_references"), { desc = "Go references" }) + :set("i", open("lsp_implementations"), { desc = "Go implementations" }) + :set("n", vim.diagnostic.goto_next, { desc = "Go next error" }) + :set("p", vim.diagnostic.goto_prev, { desc = "Go prev error" }) require("trouble").setup() end, @@ -641,13 +672,13 @@ return { local toggleterm = kit.require_on_exported_call("toggleterm") map - :prefix("t", "+toggle") - :set("t", function() - toggleterm.toggle(vim.v.count, nil, nil, "horizontal") - end) - :set("T", function() - toggleterm.toggle(vim.v.count, nil, nil, "tab") - end) + :prefix("t", "+toggle") + :set("t", function() + toggleterm.toggle(vim.v.count, nil, nil, "horizontal") + end) + :set("T", function() + toggleterm.toggle(vim.v.count, nil, nil, "tab") + end) map:ft("toggleterm"):mode("t"):set("", "") end, @@ -678,7 +709,7 @@ return { config = function() local get_input = function(prompt, default) local ok, result = - pcall(vim.fn.input, { prompt = prompt, default = default, cancelreturn = vim.NIL }) + pcall(vim.fn.input, { prompt = prompt, default = default, cancelreturn = vim.NIL }) if ok and result ~= vim.NIL then return result end @@ -800,23 +831,23 @@ return { local ls = kit.require_on_exported_call("luasnip") map - :mode("i") - :amend("", function(fallback) - if vim.fn.pumvisible() == 1 then - return vim.api.nvim_feedkeys(vim.keycode(""), "n", false) - elseif ls.expand_or_jumpable() then - return ls.expand_or_jump() - end - return fallback() - end) - :amend("", function() - if vim.fn.pumvisible() == 1 then - return vim.api.nvim_feedkeys(vim.keycode(""), "n", false) - elseif ls.jumpable(-1) then - ls.jump(-1) - end - return vim.api.nvim_feedkeys(vim.keycode(""), "n", false) - end) + :mode("i") + :amend("", function(fallback) + if vim.fn.pumvisible() == 1 then + return vim.api.nvim_feedkeys(vim.keycode(""), "n", false) + elseif ls.expand_or_jumpable() then + return ls.expand_or_jump() + end + return fallback() + end) + :amend("", function() + if vim.fn.pumvisible() == 1 then + return vim.api.nvim_feedkeys(vim.keycode(""), "n", false) + elseif ls.jumpable(-1) then + ls.jump(-1) + end + return vim.api.nvim_feedkeys(vim.keycode(""), "n", false) + end) map:mode("c"):amend("", function(fallback) if vim.fn.wildmenumode() == 1 then @@ -855,12 +886,12 @@ return { end, { desc = "ИТМО" }) map - :prefix("f", "+find") - :set("c", fzf.commands, { desc = "Commands" }) - :set("f", fzf.files, { desc = "Find files" }) - :set("g", fzf.live_grep, { desc = "Grep files" }) - :set("r", fzf.oldfiles, { desc = "Recent files" }) - :set("p", fzf.resume, { desc = "Resume last search" }) + :prefix("f", "+find") + :set("c", fzf.commands, { desc = "Commands" }) + :set("f", fzf.files, { desc = "Find files" }) + :set("g", fzf.live_grep, { desc = "Grep files" }) + :set("r", fzf.oldfiles, { desc = "Recent files" }) + :set("p", fzf.resume, { desc = "Resume last search" }) map:mode("t"):set("", [['"'.nr2char(getchar()).'pi']], { expr = true }) @@ -879,21 +910,21 @@ return { local data = vim.json.decode(result.stdout) local current_branch = vim - .iter(data) - :filter(function(value) - return value["current"] - end) - :map(function(value) - return value["name"] - end) - :totable()[1] + .iter(data) + :filter(function(value) + return value["current"] + end) + :map(function(value) + return value["name"] + end) + :totable()[1] local branch_names = vim - .iter(data) - :map(function(value) - return value["name"] - end) - :totable() + .iter(data) + :map(function(value) + return value["name"] + end) + :totable() vim.ui.select( branch_names, @@ -948,7 +979,8 @@ return { }, }, files = { - fd_opts = "--color=never --type f --hidden --follow --exclude .git --exclude .obsidian --exclude build --exclude .DS_Store --exclude Вложения", + fd_opts = + "--color=never --type f --hidden --follow --exclude .git --exclude .obsidian --exclude build --exclude .DS_Store --exclude Вложения", fzf_opts = { ["--history"] = vim.fn.stdpath("data") .. "/fzf-lua-files-history", },