Latest config changes
This commit is contained in:
parent
846e47b931
commit
a3c3abdf89
12 changed files with 110 additions and 10 deletions
2
ftplugin/cpp.lua
Normal file
2
ftplugin/cpp.lua
Normal 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
2
ftplugin/cuda.lua
Normal 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
2
ftplugin/haskell.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
vim.opt.sw = 2
|
||||||
|
vim.opt.ts = 2
|
||||||
2
ftplugin/javascript.lua
Normal file
2
ftplugin/javascript.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
vim.opt_local.shiftwidth = 2
|
||||||
|
vim.opt_local.tabstop = 2
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
set spell spellfile="~/.config/nvim/spell/wordlist"
|
set spell spellfile="~/.config/nvim/spell/wordlist"
|
||||||
|
setlocal conceallevel=0
|
||||||
|
setlocal concealcursor=
|
||||||
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'fortran']
|
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'fortran']
|
||||||
set conceallevel=2
|
|
||||||
let g:vim_markdown_math = 1
|
let g:vim_markdown_math = 1
|
||||||
let g:tex_conceal = "abdmg"
|
let g:tex_conceal = "abdmg"
|
||||||
let g:tex_superscripts= "[]"
|
let g:tex_superscripts= "[]"
|
||||||
|
|
@ -17,4 +18,3 @@ command Stab Tabularize /\s\+\zs\s/l1c0
|
||||||
nnoremap ;t :Tabularize /\s\+\zs\s/l1c0<CR>
|
nnoremap ;t :Tabularize /\s\+\zs\s/l1c0<CR>
|
||||||
set tw=1000
|
set tw=1000
|
||||||
set colorcolumn=
|
set colorcolumn=
|
||||||
|
|
||||||
|
|
|
||||||
4
ftplugin/python.lua
Normal file
4
ftplugin/python.lua
Normal 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
2
ftplugin/typescript.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
vim.opt_local.shiftwidth = 2
|
||||||
|
vim.opt_local.tabstop = 2
|
||||||
1
init.lua
1
init.lua
|
|
@ -1,5 +1,6 @@
|
||||||
-- set to true for light mode
|
-- set to true for light mode
|
||||||
vim.g.light_mode = true
|
vim.g.light_mode = true
|
||||||
|
vim.g.vim_markdown_conceal = 0
|
||||||
|
|
||||||
-- Neovim configuration
|
-- Neovim configuration
|
||||||
-- Modularized structure for better organization
|
-- Modularized structure for better organization
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,6 @@ return {
|
||||||
lsp_fallback = true,
|
lsp_fallback = true,
|
||||||
},
|
},
|
||||||
formatters = {
|
formatters = {
|
||||||
black = {
|
|
||||||
prepend_args = { "--line-length", "100" },
|
|
||||||
},
|
|
||||||
beautysh = {
|
beautysh = {
|
||||||
prepend_args = { "--indent-size", "2" },
|
prepend_args = { "--indent-size", "2" },
|
||||||
},
|
},
|
||||||
|
|
@ -25,15 +22,16 @@ return {
|
||||||
},
|
},
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { "stylua" },
|
lua = { "stylua" },
|
||||||
python = { "black" },
|
python = { "ruff_format" },
|
||||||
cpp = { "clang-format" },
|
cpp = { "clang-format" },
|
||||||
c = { "clang-format" },
|
c = { "clang-format" },
|
||||||
sh = { "beautysh" },
|
sh = { "beautysh" },
|
||||||
tex = { "latexindent" },
|
tex = { "latexindent" },
|
||||||
java = { "google-java-format" },
|
java = { "google-java-format" },
|
||||||
javascript = { "prettier" },
|
javascript = { "prettier" },
|
||||||
typescript = { "prettier" },
|
typescript = { "deno_fmt" },
|
||||||
typescriptreact = { "prettier" },
|
typescriptreact = { "deno_fmt" },
|
||||||
|
svelte = { "deno_fmt" },
|
||||||
json = { "prettier" },
|
json = { "prettier" },
|
||||||
go = { "golines" },
|
go = { "golines" },
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ return {
|
||||||
{ "j-hui/fidget.nvim", opts = {} },
|
{ "j-hui/fidget.nvim", opts = {} },
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
|
local util = require("lspconfig.util")
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
||||||
callback = function(event)
|
callback = function(event)
|
||||||
|
|
@ -103,6 +105,35 @@ return {
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_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 = {
|
local servers = {
|
||||||
clangd = {
|
clangd = {
|
||||||
filetypes = {
|
filetypes = {
|
||||||
|
|
@ -113,15 +144,43 @@ return {
|
||||||
},
|
},
|
||||||
taplo = {},
|
taplo = {},
|
||||||
yamlls = { settings = { yaml = { format = { enable = true } } } },
|
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 = {},
|
fortls = {},
|
||||||
jsonls = {},
|
jsonls = {},
|
||||||
bashls = { dependencies = "shellcheck" },
|
bashls = { dependencies = "shellcheck" },
|
||||||
kotlin_language_server = {},
|
kotlin_language_server = {},
|
||||||
gopls = {},
|
gopls = {},
|
||||||
|
denols = {},
|
||||||
ts_ls = {},
|
ts_ls = {},
|
||||||
svelte = {},
|
svelte = {},
|
||||||
arduino_language_server = {},
|
arduino_language_server = {},
|
||||||
|
zls = {},
|
||||||
ltex = {
|
ltex = {
|
||||||
settings = {
|
settings = {
|
||||||
ltex = {
|
ltex = {
|
||||||
|
|
@ -177,7 +236,7 @@ return {
|
||||||
vim.list_extend(ensure_installed, {
|
vim.list_extend(ensure_installed, {
|
||||||
"jdtls",
|
"jdtls",
|
||||||
"stylua",
|
"stylua",
|
||||||
"black",
|
"ruff",
|
||||||
"golines",
|
"golines",
|
||||||
"clang-format",
|
"clang-format",
|
||||||
"beautysh",
|
"beautysh",
|
||||||
|
|
@ -192,9 +251,12 @@ return {
|
||||||
local server = servers[server_name] or {}
|
local server = servers[server_name] or {}
|
||||||
require("lspconfig")[server_name].setup({
|
require("lspconfig")[server_name].setup({
|
||||||
cmd = server.cmd,
|
cmd = server.cmd,
|
||||||
|
on_attach = server.on_attach,
|
||||||
|
before_init = server.before_init,
|
||||||
on_init = function(client)
|
on_init = function(client)
|
||||||
client.offset_encoding = "utf-8"
|
client.offset_encoding = "utf-8"
|
||||||
end,
|
end,
|
||||||
|
root_dir = server.root_dir,
|
||||||
settings = server.settings,
|
settings = server.settings,
|
||||||
filetypes = server.filetypes,
|
filetypes = server.filetypes,
|
||||||
capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}),
|
capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}),
|
||||||
|
|
|
||||||
25
lua/workspace.lua
Normal file
25
lua/workspace.lua
Normal 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.
Loading…
Add table
Add a link
Reference in a new issue