diff --git a/lazy-lock.json b/lazy-lock.json index 3332898..e27898a 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -47,7 +47,7 @@ "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-scrollview": { "branch": "main", "commit": "fd334e5ad0c616987d1b9114890a59c97165cf83" }, "nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" }, - "nvim-treesitter": { "branch": "master", "commit": "b967bbc27b564001c3d3b8ea93444cf6d0b21d23" }, + "nvim-treesitter": { "branch": "master", "commit": "122b4d3db1616c1f1305b847c5ed2217c4c329f1" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, diff --git a/lua/user/lsp/mason_cfg.lua b/lua/user/lsp/mason_cfg.lua index 9139041..1900e60 100644 --- a/lua/user/lsp/mason_cfg.lua +++ b/lua/user/lsp/mason_cfg.lua @@ -1,59 +1,59 @@ local servers = { - "lua_ls", + "lua_ls", } local function idxOf(array, value) - for i, v in ipairs(array) do - if v == value then - return i - end - end - return nil + for i, v in ipairs(array) do + if v == value then + return i + end + end + return nil end local mason_install = pcode.mason_ensure_installed or {} for _, client in pairs(mason_install) do - table.insert(servers, client) + table.insert(servers, client) end local unregis_lsp = pcode.unregister_lsp or {} local icons = vim.g.pcode_icons.ui local settings = { - ui = { - -- border = "none", - border = icons.Border, - icons = { - package_pending = icons.DotCircle, - package_installed = icons.CheckCircle, - package_uninstalled = icons.BlankCircle, - }, - keymaps = { - -- Keymap to expand a server in the UI - toggle_server_expand = "", - -- Keymap to install the server under the current cursor position - install_server = "i", - -- Keymap to reinstall/update the server under the current cursor position - update_server = "u", - -- Keymap to check for new version for the server under the current cursor position - check_server_version = "c", - -- Keymap to update all installed servers - update_all_servers = "U", - -- Keymap to check which installed servers are outdated - check_outdated_servers = "C", - -- Keymap to uninstall a server - uninstall_server = "X", - }, - }, - log_level = vim.log.levels.INFO, - max_concurrent_installers = 4, + ui = { + -- border = "none", + border = icons.Border, + icons = { + package_pending = icons.DotCircle, + package_installed = icons.CheckCircle, + package_uninstalled = icons.BlankCircle, + }, + keymaps = { + -- Keymap to expand a server in the UI + toggle_server_expand = "", + -- Keymap to install the server under the current cursor position + install_server = "i", + -- Keymap to reinstall/update the server under the current cursor position + update_server = "u", + -- Keymap to check for new version for the server under the current cursor position + check_server_version = "c", + -- Keymap to update all installed servers + update_all_servers = "U", + -- Keymap to check which installed servers are outdated + check_outdated_servers = "C", + -- Keymap to uninstall a server + uninstall_server = "X", + }, + }, + log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, } require("mason").setup(settings) -- * buka remark ini jika akan menggunakan list serverrs diatas dan remark config dibawah require("mason-lspconfig").setup({ - ensure_installed = servers, - automatic_installation = true, + ensure_installed = servers, + automatic_installation = true, }) -- -- * buka remark ini jika ingin menjalankan dengan cara install dan remark config diatas (pilih satu) @@ -61,46 +61,50 @@ require("mason-lspconfig").setup({ local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") if not lspconfig_status_ok then - return + return end local opts = {} require("mason-lspconfig").setup_handlers({ - function(server_name) -- default handler (optional) - local is_skip = false - local my_index = idxOf(unregis_lsp, server_name) - if my_index ~= nil then - is_skip = true - end - if not is_skip then - opts = { - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, - } + function(server_name) -- default handler (optional) + local capabilities = require("user.lsp.handlers").capabilities + if server_name == "clangd" then + capabilities.offsetEncoding = { "utf-16" } + end + local is_skip = false + local my_index = idxOf(unregis_lsp, server_name) + if my_index ~= nil then + is_skip = true + end + if not is_skip then + opts = { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = capabilities, + } - server_name = vim.split(server_name, "@")[1] + server_name = vim.split(server_name, "@")[1] - local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server_name) - if require_ok then - opts = vim.tbl_deep_extend("force", conf_opts, opts) - end - lspconfig[server_name].setup(opts) - end - end, - -- Next, you can provide targeted overrides for specific servers. - -- ["rust_analyzer"] = function() - -- require("rust-tools").setup({}) - -- end, - -- ["lua_ls"] = function() - -- lspconfig.sumneko_lua.setup({ - -- settings = { - -- Lua = { - -- diagnostics = { - -- globals = { "vim" }, - -- }, - -- }, - -- }, - -- }) - -- end, + local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server_name) + if require_ok then + opts = vim.tbl_deep_extend("force", conf_opts, opts) + end + lspconfig[server_name].setup(opts) + end + end, + -- Next, you can provide targeted overrides for specific servers. + -- ["rust_analyzer"] = function() + -- require("rust-tools").setup({}) + -- end, + -- ["lua_ls"] = function() + -- lspconfig.sumneko_lua.setup({ + -- settings = { + -- Lua = { + -- diagnostics = { + -- globals = { "vim" }, + -- }, + -- }, + -- }, + -- }) + -- end, })