From a3c3abdf89ffd1380d17a7df06c4581fe97190fa Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Fri, 17 Jul 2026 10:54:11 -0400 Subject: [PATCH] Latest config changes --- ftplugin/cpp.lua | 2 ++ ftplugin/cuda.lua | 2 ++ ftplugin/haskell.lua | 2 ++ ftplugin/javascript.lua | 2 ++ ftplugin/markdown.vim | 4 +-- ftplugin/python.lua | 4 +++ ftplugin/typescript.lua | 2 ++ init.lua | 1 + lua/plugins/formatting.lua | 10 +++--- lua/plugins/lsp.lua | 66 +++++++++++++++++++++++++++++++++++-- lua/workspace.lua | 25 ++++++++++++++ spell/en.utf-8.add.spl | Bin 793 -> 859 bytes 12 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 ftplugin/cpp.lua create mode 100644 ftplugin/cuda.lua create mode 100644 ftplugin/haskell.lua create mode 100644 ftplugin/javascript.lua create mode 100644 ftplugin/python.lua create mode 100644 ftplugin/typescript.lua create mode 100644 lua/workspace.lua diff --git a/ftplugin/cpp.lua b/ftplugin/cpp.lua new file mode 100644 index 0000000..93eb969 --- /dev/null +++ b/ftplugin/cpp.lua @@ -0,0 +1,2 @@ +vim.keymap.set({ "v", "n", "i" }, "", ": CMakeBuild") +vim.keymap.set({ "v", "n", "i" }, "", ": CMakeTest") diff --git a/ftplugin/cuda.lua b/ftplugin/cuda.lua new file mode 100644 index 0000000..93eb969 --- /dev/null +++ b/ftplugin/cuda.lua @@ -0,0 +1,2 @@ +vim.keymap.set({ "v", "n", "i" }, "", ": CMakeBuild") +vim.keymap.set({ "v", "n", "i" }, "", ": CMakeTest") diff --git a/ftplugin/haskell.lua b/ftplugin/haskell.lua new file mode 100644 index 0000000..de76f40 --- /dev/null +++ b/ftplugin/haskell.lua @@ -0,0 +1,2 @@ +vim.opt.sw = 2 +vim.opt.ts = 2 diff --git a/ftplugin/javascript.lua b/ftplugin/javascript.lua new file mode 100644 index 0000000..9dfd152 --- /dev/null +++ b/ftplugin/javascript.lua @@ -0,0 +1,2 @@ +vim.opt_local.shiftwidth = 2 +vim.opt_local.tabstop = 2 diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index 99d0d3e..62f3455 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -1,6 +1,7 @@ set spell spellfile="~/.config/nvim/spell/wordlist" +setlocal conceallevel=0 +setlocal concealcursor= let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'fortran'] -set conceallevel=2 let g:vim_markdown_math = 1 let g:tex_conceal = "abdmg" let g:tex_superscripts= "[]" @@ -17,4 +18,3 @@ command Stab Tabularize /\s\+\zs\s/l1c0 nnoremap ;t :Tabularize /\s\+\zs\s/l1c0 set tw=1000 set colorcolumn= - diff --git a/ftplugin/python.lua b/ftplugin/python.lua new file mode 100644 index 0000000..dd78580 --- /dev/null +++ b/ftplugin/python.lua @@ -0,0 +1,4 @@ +vim.opt_local.colorcolumn = "88" +vim.opt_local.textwidth = 1000 +vim.keymap.set("n", "x", "[hv]h]hk$;sc", { buffer = true }) +vim.keymap.set("n", "r", ":!python3 %", { buffer = true }) diff --git a/ftplugin/typescript.lua b/ftplugin/typescript.lua new file mode 100644 index 0000000..9dfd152 --- /dev/null +++ b/ftplugin/typescript.lua @@ -0,0 +1,2 @@ +vim.opt_local.shiftwidth = 2 +vim.opt_local.tabstop = 2 diff --git a/init.lua b/init.lua index 1e2bed7..f0925a4 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,6 @@ -- set to true for light mode vim.g.light_mode = true +vim.g.vim_markdown_conceal = 0 -- Neovim configuration -- Modularized structure for better organization diff --git a/lua/plugins/formatting.lua b/lua/plugins/formatting.lua index 8b9fe39..1faa2a2 100644 --- a/lua/plugins/formatting.lua +++ b/lua/plugins/formatting.lua @@ -10,9 +10,6 @@ return { lsp_fallback = true, }, formatters = { - black = { - prepend_args = { "--line-length", "100" }, - }, beautysh = { prepend_args = { "--indent-size", "2" }, }, @@ -25,15 +22,16 @@ return { }, formatters_by_ft = { lua = { "stylua" }, - python = { "black" }, + python = { "ruff_format" }, cpp = { "clang-format" }, c = { "clang-format" }, sh = { "beautysh" }, tex = { "latexindent" }, java = { "google-java-format" }, javascript = { "prettier" }, - typescript = { "prettier" }, - typescriptreact = { "prettier" }, + typescript = { "deno_fmt" }, + typescriptreact = { "deno_fmt" }, + svelte = { "deno_fmt" }, json = { "prettier" }, go = { "golines" }, }, diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 2b344c0..477b6a8 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -64,6 +64,8 @@ return { { "j-hui/fidget.nvim", opts = {} }, }, config = function() + local util = require("lspconfig.util") + vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), callback = function(event) @@ -103,6 +105,35 @@ return { local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) + local function is_executable(path) + return path and vim.fn.executable(path) == 1 + end + + local function get_python_path(root_dir) + local candidates = {} + local active_venv = os.getenv("VIRTUAL_ENV") + + if root_dir then + vim.list_extend(candidates, { + util.path.join(root_dir, ".venv", "bin", "python"), + util.path.join(root_dir, "venv", "bin", "python"), + }) + end + + if active_venv then + table.insert(candidates, util.path.join(active_venv, "bin", "python")) + end + + table.insert(candidates, vim.fn.exepath("python3")) + table.insert(candidates, vim.fn.exepath("python")) + + for _, path in ipairs(candidates) do + if is_executable(path) then + return path + end + end + end + local servers = { clangd = { filetypes = { @@ -113,15 +144,43 @@ return { }, taplo = {}, yamlls = { settings = { yaml = { format = { enable = true } } } }, - pyright = {}, + pyright = { + root_dir = util.root_pattern( + "pyproject.toml", + "uv.lock", + "setup.py", + "setup.cfg", + "requirements.txt", + ".git" + ), + before_init = function(_, config) + local python_path = get_python_path(config.root_dir) + config.settings = vim.tbl_deep_extend("force", config.settings or {}, { + python = { + pythonPath = python_path, + analysis = { + autoSearchPaths = true, + useLibraryCodeForTypes = true, + }, + }, + }) + end, + }, + ruff = { + on_attach = function(client) + client.server_capabilities.documentFormattingProvider = false + end, + }, fortls = {}, jsonls = {}, bashls = { dependencies = "shellcheck" }, kotlin_language_server = {}, gopls = {}, + denols = {}, ts_ls = {}, svelte = {}, arduino_language_server = {}, + zls = {}, ltex = { settings = { ltex = { @@ -177,7 +236,7 @@ return { vim.list_extend(ensure_installed, { "jdtls", "stylua", - "black", + "ruff", "golines", "clang-format", "beautysh", @@ -192,9 +251,12 @@ return { local server = servers[server_name] or {} require("lspconfig")[server_name].setup({ cmd = server.cmd, + on_attach = server.on_attach, + before_init = server.before_init, on_init = function(client) client.offset_encoding = "utf-8" end, + root_dir = server.root_dir, settings = server.settings, filetypes = server.filetypes, capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}), diff --git a/lua/workspace.lua b/lua/workspace.lua new file mode 100644 index 0000000..0f851e5 --- /dev/null +++ b/lua/workspace.lua @@ -0,0 +1,25 @@ +local util = require('lspconfig.util') + +local join = util.path.join + +local M = {} + +local env = { + HOME = vim.loop.os_homedir(), + XDG_CACHE_HOME = os.getenv('XDG_CACHE_HOME'), +} + +---Returns the default workspace directory +---@return string +function M.get_default_workspace() + local cache_dir = env.XDG_CACHE_HOME and env.XDG_CACHE_HOME + or join(env.HOME, '.cache') + local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') + + local path = + join(cache_dir, 'jdtls', 'workspaces', project_name) + + return path +end + +return M diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl index a710b76d9f0d581c0137d36523e700e123b86441..b8bc973a2cf31b3676519281a4f9a632d253d307 100644 GIT binary patch literal 859 zcmX|9L5>qK5OkYxa)b#;IF^w{Q@^M}92*zfP05AiglvCOrtJ5$>tUIt0BNW_WnAl6EgRYp8X ziad#tNzV-dNxU^;%)Z$;0bQg5O@gaKK-7${rU?^HMVw@7GU5Hj#v~co8D%PvBfg?S zO-^`LGVOE*?FMX21@64O9n16i1(d4E7mXM}FPebLE2Ku12*&1-u9qXnX>U{!AS(l7 zD-*d}Q3sB_(yv7(TM3f{_@SUg&;<96n1%v-QTEH|RSjIpxmGE5Ug|%?;!WdO_G$p|C5<*7fWK z7UmJReSsAHNwc8s_hMaDZ?le&`vBJUE7vLDgIm~Fq=3-~J~Z`DPH`6p^zK(Q&}Scr z|8a=pI%%pOSF&}Mu+gI=Bg7{mdc%aeKGgn EKVl86u*^1Lv)NS0X!{CkPA6CZ;%f%31 z_6JasHZNK+fF89$(Uv{F6xI}Tt|zV|B9Q{>XM+X=~PDSI_2_*>s1{)9`T*3-QP zUt)Slbo{!?OV^Jx=5cydtC7AfwuwlNiw2g}bK%*|RnTfcuKX{7A?tc_XVHoC)*eCz zoy^VA_6Da%{WfHfkJZ7HAgYQ9)^ULW)uRmqvh~U+`c@s6_hMawHuj=zya8aHUU`99 z1oW+5iU>Fp{LX5bJo<(2D3We*-