Latest config changes

This commit is contained in:
Alex Selimov 2026-07-17 10:54:11 -04:00
parent 846e47b931
commit a3c3abdf89
12 changed files with 110 additions and 10 deletions

2
ftplugin/cpp.lua Normal file
View file

@ -0,0 +1,2 @@
vim.keymap.set({ "v", "n", "i" }, "<C-b>", ": CMakeBuild<CR>")
vim.keymap.set({ "v", "n", "i" }, "<C-t>", ": CMakeTest<CR>")

2
ftplugin/cuda.lua Normal file
View file

@ -0,0 +1,2 @@
vim.keymap.set({ "v", "n", "i" }, "<C-b>", ": CMakeBuild<CR>")
vim.keymap.set({ "v", "n", "i" }, "<C-t>", ": CMakeTest<CR>")

2
ftplugin/haskell.lua Normal file
View file

@ -0,0 +1,2 @@
vim.opt.sw = 2
vim.opt.ts = 2

2
ftplugin/javascript.lua Normal file
View file

@ -0,0 +1,2 @@
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2

View file

@ -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<CR>
set tw=1000
set colorcolumn=

4
ftplugin/python.lua Normal file
View file

@ -0,0 +1,4 @@
vim.opt_local.colorcolumn = "88"
vim.opt_local.textwidth = 1000
vim.keymap.set("n", "<leader>x", "[hv]h]hk$;sc", { buffer = true })
vim.keymap.set("n", "<leader>r", ":!python3 %<CR>", { buffer = true })

2
ftplugin/typescript.lua Normal file
View file

@ -0,0 +1,2 @@
vim.opt_local.shiftwidth = 2
vim.opt_local.tabstop = 2

View file

@ -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

View file

@ -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" },
},

View file

@ -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 {}),

25
lua/workspace.lua Normal file
View file

@ -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

Binary file not shown.