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 a710b76..b8bc973 100644 Binary files a/spell/en.utf-8.add.spl and b/spell/en.utf-8.add.spl differ