From dbb9af29d56e0894688637c805c3fdccac5067cd Mon Sep 17 00:00:00 2001 From: Ian Griffin Date: Mon, 18 Aug 2025 11:07:22 +0800 Subject: [PATCH] minor updates --- lua/binds.lua | 45 ++++++++++++++++++++++++++++++++++++++++++ lua/lazy_conf.lua | 4 ++-- lua/plugins/10_ide.lua | 30 ++++++++++++++++++++++------ lua/plugins/50_ui.lua | 2 +- 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/lua/binds.lua b/lua/binds.lua index beef6fb..291bfb8 100644 --- a/lua/binds.lua +++ b/lua/binds.lua @@ -29,6 +29,51 @@ ct.map('n', 'wq', 'wbd') -- netrw ct.map('n', 'e', 'Explore') +-- +-- LSP +-- +local lsp_buf = vim.lsp.buf + +-- Function to convert snake_case to PascalCase +local function snake_to_pascal(name) + return name:gsub('_', ''):gsub("(%a)(%w*)", function(first, rest) + return first:upper() .. rest:lower() + end) +end + +for func_name, _ in pairs(lsp_buf) do + if type(lsp_buf[func_name]) == "function" then -- Check if the value is a function + local command_name = 'LspBuf' .. snake_to_pascal(func_name) + vim.api.nvim_create_user_command( + command_name, + function() + lsp_buf[func_name]() -- Call the function from the table + end, + {desc = "Run LSP Buffer Function: " .. func_name} + ) + end +end + +function toggle_background() + local bg = vim.o.background + + if bg == "dark" then + vim.cmd("set background=light") + else + vim.cmd("set background=dark") + end + + -- Query the current colorscheme + --[[ local colorscheme = vim.fn.executable('colorscheme') or "" + -- colorscheme = colorscheme:match("^%s*(.-)%s*$") + + -- Reload the colorscheme if it was set + if colorscheme ~= "" then + vim.cmd("colorscheme " .. colorscheme) + end ]]-- +end + +ct.map('n', 'b', 'lua toggle_background()') -- -- Commands -- diff --git a/lua/lazy_conf.lua b/lua/lazy_conf.lua index 5398756..fe357d9 100644 --- a/lua/lazy_conf.lua +++ b/lua/lazy_conf.lua @@ -8,7 +8,7 @@ require("lazy").setup({ }, -- Configure any other settings here. See the documentation for more details. -- colorscheme that will be used when installing plugins. - install = { colorscheme = { "onedark" } }, + install = { colorscheme = { "enfocado" } }, -- automatically check for plugin updates - checker = { enabled = true }, + checker = { enabled = false }, }) diff --git a/lua/plugins/10_ide.lua b/lua/plugins/10_ide.lua index 7de1d01..a3ec510 100644 --- a/lua/plugins/10_ide.lua +++ b/lua/plugins/10_ide.lua @@ -1,7 +1,7 @@ return { { 'nvim-treesitter/nvim-treesitter', - -- build = ':TSUpdate', + build = ':TSUpdate', event = { "VeryLazy" }, lazy = vim.fn.argc(-1) == 0, opts = { @@ -21,6 +21,7 @@ return { "lua", "php", "python", + "sql", "typescript", "tsx", "vim", @@ -56,8 +57,13 @@ return { { 'ap/vim-css-color', lazy = false }, -- close tags in html languages { - 'alvan/closetag.vim', - ft = { "html", "vue", "typescriptreact" }, + 'alvan/vim-closetag', + ft = { "html", "vue", "javascriptreact", "typescriptreact", "xml" }, + config = function() + vim.g.closetag_xhtml_filenames = '*.xhtml,*.js,*.tsx' + vim.g.clostag_xhtml_filetypes = 'xhtm,jsx,tsx' + vim.cmd [[ CloseTagEnableBuffer ]] + end, }, { @@ -134,17 +140,17 @@ return { vim.diagnostic.config({ virtual_text = false }) end }, - { + --[[{ 'huggingface/llm.nvim', opts = { - model = 'qwen2.5-coder:7b', + model = 'qwen2.5-coder:latest', backend = 'ollama', url = 'http://localhost:11434', lsp = { bin_path = vim.api.nvim_call_function("stdpath", { "data" }) .. "/mason/bin/llm-ls", } }, - }, + }, ]]-- { 'mason-org/mason-lspconfig.nvim', dependencies = { @@ -165,6 +171,7 @@ return { "lua_ls", "phpactor", "pyright", + "sqls", "texlab", "ts_ls" }, @@ -183,10 +190,21 @@ return { "lua", "php", "python", + "sql", "tex", "typescript", "typescriptreact", }, + --[[ config = function() + vim.lsp.config('*', require('coq').lsp_ensure_capabilities { + on_attach = function(client, bufnr) + local basics = require('lsp_basics') + basics.make_lsp_commands(client, bufnr) + basics.make_lsp_mappings(client, bufnr) + end + }) + end, ]]-- + -- config = function() -- local masonlsp = require 'mason-lspconfig' -- --[[ diff --git a/lua/plugins/50_ui.lua b/lua/plugins/50_ui.lua index f670b7d..9d19a3b 100644 --- a/lua/plugins/50_ui.lua +++ b/lua/plugins/50_ui.lua @@ -43,7 +43,7 @@ return { lazy = false, init = function() vim.g.indent_guides_guide_size = 1 - vim.g.indent_guides_tab_guides = 0 + vim.g.indent_guides_tab_guides = 0 vim.g.indent_guides_start_level = 2 vim.g.indent_guides_enable_on_vim_startup = 1 end