diff --git a/after/ftplugin/freemarker.lua b/after/ftplugin/freemarker.lua index 80fb087..d6ec1d0 100644 --- a/after/ftplugin/freemarker.lua +++ b/after/ftplugin/freemarker.lua @@ -1,3 +1,4 @@ +------------------------------------- ----- File : freemarker.lua ----- Description : filetype freemarker extra config ----- Author : Kevin @@ -25,4 +26,3 @@ vim.lsp.start { filetypes = { "freemarker", "ftl" }, root_dir = vim.fs.dirname(vim.api.nvim_buf_get_name(0)), on_attach = require "plugins.lsp".on_attach -} \ No newline at end of file diff --git a/after/ftplugin/pdf.lua b/after/ftplugin/pdf.lua new file mode 100644 index 0000000..5b37935 --- /dev/null +++ b/after/ftplugin/pdf.lua @@ -0,0 +1,16 @@ +------------------------------------- +-- File : pdf.lua +-- Description : filetype PDF extra config +-- Author : Kevin +-- Last Modified: 05/01/2025 - 11:39 +------------------------------------- + + +vim.api.nvim_set_option_value("readonly", true, { buf = 0 }) +if not vim.fn.executable "pdftotext" then + vim.notify("vim-pdf: pdftotext is not found.\nStop converting...", vim.log.levels.ERROR) + return +end + +---Read PDF into neovim, using pdftotext binary +require("lib.pdf").load_pdf(vim.api.nvim_buf_get_name(0)) diff --git a/after/ftplugin/qf.lua b/after/ftplugin/qf.lua index d72c4cc..18b943b 100644 --- a/after/ftplugin/qf.lua +++ b/after/ftplugin/qf.lua @@ -13,5 +13,16 @@ local del_qf_item = function() vim.api.nvim_win_set_cursor(0, { line, 0 }) end +---Keymaps vim.keymap.set("n", "dd", del_qf_item, { silent = true, buffer = true, desc = "Remove entry from QF" }) -vim.keymap.set("v", "D", del_qf_item, { silent = true, buffer = true, desc = "Remove entry from QF" }) \ No newline at end of file +vim.keymap.set("v", "D", del_qf_item, { silent = true, buffer = true, desc = "Remove entry from QF" }) + +vim.keymap.set("n", "", "cprev", { buffer = true, silent = true }) +vim.keymap.set("n", "", "cnext", { buffer = true, silent = true }) +vim.keymap.set("n", "", "", { buffer = true, silent = true }) +vim.keymap.set("n", "q", function() + vim.cmd.quit { bang = true } +end, { buffer = true, silent = true }) +vim.keymap.set("n", "", function() + vim.cmd.quit { bang = true } +end, { buffer = true, silent = true }) \ No newline at end of file diff --git a/lazy-lock.json b/lazy-lock.json index d5089f4..83b15d7 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,45 +1,45 @@ { - "SchemaStore.nvim": { "branch": "main", "commit": "fa47222e29d6f6e80eddcdd0f125c27edf274ad5" }, + "SchemaStore.nvim": { "branch": "main", "commit": "118e563101169e8c5096023bc45c460e4c4fb77c" }, "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" }, - "blink.cmp": { "branch": "main", "commit": "e3b7cb4a1094377c3093a021300de123d9fc60d3" }, + "blink.cmp": { "branch": "main", "commit": "b6f11a0aa33e601c469a126e3ed6e35208fe3ea3" }, "color-picker.nvim": { "branch": "master", "commit": "06cb5f853535dea529a523e9a0e8884cdf9eba4d" }, - "conform.nvim": { "branch": "master", "commit": "70019124aa4f2e6838be9fbd2007f6d13b27a96d" }, + "conform.nvim": { "branch": "master", "commit": "363243c03102a531a8203311d4f2ae704c620d9b" }, "data-viewer.nvim": { "branch": "main", "commit": "40ddf37bb7ab6c04ff9e820812d1539afe691668" }, - "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, + "gitsigns.nvim": { "branch": "main", "commit": "c23bbd3ed2c7a3fdc3399e97e24f9e158f57612f" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "kurayami.nvim": { "branch": "main", "commit": "57af5981ee831d53f7a61d697a50f4bda0f681de" }, - "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "lazy.nvim": { "branch": "main", "commit": "f15a93907ddad3d9139aea465ae18336d87f5ce6" }, "lazydev.nvim": { "branch": "main", "commit": "8620f82ee3f59ff2187647167b6b47387a13a018" }, - "markdown.nvim": { "branch": "main", "commit": "1faa6568eb61467d64c3d0aad8ac4c9c0e45514e" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" }, + "markdown.nvim": { "branch": "main", "commit": "17a77463f945c4b9e4f371c752efd90e3e1bf604" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f75e877f5266e87523eb5a18fcde2081820d087b" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.icons": { "branch": "main", "commit": "6787321f70d674a481776b7cc2c781fb7002c644" }, - "mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" }, - "mini.surround": { "branch": "main", "commit": "aa5e245829dd12d8ff0c96ef11da28681d6049aa" }, - "molten-nvim": { "branch": "main", "commit": "c621baf53459a6c45dfd98dcc11cbba7a7ae9470" }, + "mini.icons": { "branch": "main", "commit": "ec61af6e606fc89ee3b1d8f2f20166a3ca917a36" }, + "mini.pairs": { "branch": "main", "commit": "1a3e73649c0eaef2f6c48ce1e761c6f0a7c11918" }, + "mini.surround": { "branch": "main", "commit": "f40be56134835421061bf32c3702de9a29fb789c" }, + "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-dap": { "branch": "master", "commit": "0e673accbb512e1e191dfb4fecea89cc38c1bcdd" }, - "nvim-dap-ui": { "branch": "master", "commit": "e94d98649dccb6a3884b66aabc2e07beb279e535" }, - "nvim-dbee": { "branch": "master", "commit": "21d2cc0844a16262bb6ea93ab3d0a0f20bd87853" }, - "nvim-jdtls": { "branch": "master", "commit": "266d0cb912bbe61d66b43c5e73db19a364380360" }, - "nvim-lint": { "branch": "master", "commit": "1fea92f1d9908eaa5eb8bafe08b4293d7aadaa55" }, - "nvim-lspconfig": { "branch": "master", "commit": "f4ed656e876e45cf914d7beb972830561178e232" }, - "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-notify": { "branch": "master", "commit": "bd9cd51f9ef2f6326fc2bc9931d0718c1794e247" }, - "nvim-treesitter": { "branch": "master", "commit": "57713d079c3c2afcc31f3e0650bf8594a2a296ba" }, + "nvim-dap": { "branch": "master", "commit": "52302f02fea3a490e55475de52fa4deb8af2eb11" }, + "nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" }, + "nvim-dbee": { "branch": "master", "commit": "f9aa10f113ae439ef20c6d8b91b27dab93274360" }, + "nvim-jdtls": { "branch": "master", "commit": "3cdd09f336ab7169476b936c0825213d86d32e41" }, + "nvim-lint": { "branch": "master", "commit": "6e9dd545a1af204c4022a8fcd99727ea41ffdcc8" }, + "nvim-lspconfig": { "branch": "master", "commit": "75edb91a3d2deabe76a9911cde2c13d411b3b097" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-notify": { "branch": "master", "commit": "22f29093eae7785773ee9d543f8750348b1a195c" }, + "nvim-treesitter": { "branch": "master", "commit": "48f7ce34ef274af10a3b2aa24932a310b1bd055d" }, "nvim-treesitter-refactor": { "branch": "master", "commit": "d8b74fa87afc6a1e97b18da23e762efb032dc270" }, - "nvim-ufo": { "branch": "main", "commit": "32cb247b893a384f1888b9cd737264159ecf183c" }, + "nvim-ufo": { "branch": "main", "commit": "81f5ffa6e8ba27c48403cf681d4b383d924e03e4" }, "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, - "oil.nvim": { "branch": "master", "commit": "c6a39a69b2df7c10466f150dde0bd23e49c1fba3" }, - "otter.nvim": { "branch": "main", "commit": "e8c662e1aefa8b483cfba6e00729a39a363dcecc" }, - "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "oil.nvim": { "branch": "master", "commit": "add50252b5e9147c0a09d36480d418c7e2737472" }, + "otter.nvim": { "branch": "main", "commit": "0e42fa795c35c7190935e3beda3791189c41bb72" }, + "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, - "quarto-nvim": { "branch": "main", "commit": "1cb2d24d7793241bd43f38e3a6f99a6d11f84458" }, + "quarto-nvim": { "branch": "main", "commit": "abc417c7e7422033f1090c0da5f30ef3ecb0c7ca" }, "rest.nvim": { "branch": "main", "commit": "c7944769dc489b9e4bc493e40820c2818eab2569" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc" }, - "vimtex": { "branch": "master", "commit": "56def42c4f3007979c38001518ebb92ea8fb5f72" }, - "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" } + "telescope.nvim": { "branch": "master", "commit": "415af52339215926d705cccc08145f3782c4d132" }, + "vimtex": { "branch": "master", "commit": "dfaf26c2cafddf61963ebeff28437352002691ac" }, + "which-key.nvim": { "branch": "main", "commit": "0e76a87ac51772569aec678dc74baa8e2a86100c" } } diff --git a/lua/lib/session.lua b/lua/lib/session.lua index 9e25a2d..ad587f2 100644 --- a/lua/lib/session.lua +++ b/lua/lib/session.lua @@ -5,7 +5,7 @@ -- Last Modified: 08 Sep 2024, 11:06 ------------------------------------- -local session = { +local M = { dir = string.format("%s/session", vim.fn.stdpath "state"), } @@ -14,7 +14,7 @@ local session = { local function get_sessions() local sessions = {} - local sessions_files = vim.split(vim.fn.globpath(session.dir, "*.vim"), "\n", { trimempty = true }) + local sessions_files = vim.split(vim.fn.globpath(M.dir, "*.vim"), "\n", { trimempty = true }) for _, f in pairs(sessions_files) do table.insert(sessions, f) @@ -84,10 +84,10 @@ local function save_session() default = nil, }, function(input) if input then - if vim.fn.isdirectory(session.dir) ~= 1 then - vim.fn.mkdir(session.dir, "pR") + if vim.fn.isdirectory(M.dir) ~= 1 then + vim.fn.mkdir(M.dir, "pR") end - local new_session_path = string.format("%s/%s.vim", session.dir, input) + local new_session_path = string.format("%s/%s.vim", M.dir, input) vim.cmd.mksession { new_session_path, bang = true } -- vim.cmd("mksession! " .. mks_path) vim.notify(string.format("Session < %s > created!", input), vim.log.levels.INFO) @@ -96,13 +96,25 @@ local function save_session() end ---Helper function to usercmd completion -function session.usercmd_session_completion() +function M.usercmd_session_completion() local args = { "restore", "save", "delete" } return table.concat(args, "\n") end -function session.select(arg) - if arg == "save" then +function M.select(arg) + if arg == "" then + vim.ui.select({ "save", "delete", "restore" }, { + prompt = "Sessions> choose", + }, function(choice) + if choice == "save" then + save_session() + elseif choice == "delete_session" then + delete_session() + elseif choice == "restore_session" then + restore_session() + end + end) + elseif arg == "save" then save_session() elseif arg == "restore" then restore_session() @@ -113,4 +125,4 @@ function session.select(arg) end end -return session +return M diff --git a/lua/lib/ui/statusline.lua b/lua/lib/ui/statusline.lua index 014275d..db07dd8 100644 --- a/lua/lib/ui/statusline.lua +++ b/lua/lib/ui/statusline.lua @@ -5,7 +5,7 @@ -- Last Modified: 26 Dec 2024, 11:00 ----------------------------------------- -local sl = { +local M = { ---name of the session session_name = "", ---filetypes to exclude @@ -19,7 +19,7 @@ local sl = { lazy = true, mason = true, noice = true, - + terminal = true, checkhealth = true, WhichKey = true, query = true, @@ -35,7 +35,7 @@ local sl = { git_status_full = 110, diagnostic = 128, row_onTot = 100, - lsp_info = 100, + lsp_info = 60, }, { __index = function() return 80 @@ -147,11 +147,11 @@ end ---Get active Nvim mode and the highlight group ---@return string mode colorful mode or mode_code local function get_mode() - local nmode = sl.colors.Nmode - local vmode = sl.colors.Vmode - local cmode = sl.colors.Cmode - local tmode = sl.colors.Tmode - local imode = sl.colors.Imode + local nmode = M.colors.Nmode + local vmode = M.colors.Vmode + local cmode = M.colors.Cmode + local tmode = M.colors.Tmode + local imode = M.colors.Imode local mode = { ["n"] = nmode .. "N", @@ -188,7 +188,7 @@ local function get_mode() ["r"] = tmode .. "R", ["rm"] = nmode .. "M", ["r?"] = nmode .. "C", - ["!"] = sl.colors.ShellMode .. "S", + ["!"] = M.colors.ShellMode .. "S", ["t"] = tmode .. "T", } @@ -212,9 +212,8 @@ end ---Get location in current buffer (current row on total rows) ---@return string line number on total number local function get_line_onTot() - return win_is_smaller(sl.preset_width.row_onTot) - and string.format(" %s%%l%s/%%L ", sl.colors.git, sl.colors.fformatloc) - or string.format(" %s%%l%s/%%L|%%P", sl.colors.git, sl.colors.fformatloc) + return win_is_smaller(M.preset_width.row_onTot) and string.format(" %s%%l%s/%%L ", M.colors.git, M.colors.fformatloc) + or string.format(" %s%%l%s/%%L|%%P", M.colors.git, M.colors.fformatloc) end ---Get file name @@ -244,22 +243,22 @@ local function get_lsp_diagnostic() status_ok = #diagnostics == 0 -- display values only if there are any - return status_ok and sl.colors.diag .. sl.icons.status_ok - or do_not_show_diag and sl.colors.diag .. sl.icons.status_not_ok + return status_ok and M.colors.diag .. M.icons.status_ok + or do_not_show_diag and M.colors.diag .. M.icons.status_not_ok or string.format( "%s%s%s %d %s%s %d %s%s %d %s%s %d", - sl.colors.diag, - sl.colors.diagError, - sl.icons.error, + M.colors.diag, + M.colors.diagError, + M.icons.error, errors, - sl.colors.diagWarn, - sl.icons.warning, + M.colors.diagWarn, + M.icons.warning, warns, - sl.colors.diagInfo, - sl.icons.information, + M.colors.diagInfo, + M.icons.information, infos, - sl.colors.diagHint, - sl.icons.hint, + M.colors.diagHint, + M.icons.hint, hints ) end @@ -269,8 +268,8 @@ end local function get_lsp_progress() local lsp = vim.lsp.status() if lsp then - lsp = lsp:gsub("(%d+%%)", "%1%%") --:gsub("%s+", " ") - return (#lsp > 40) and string.sub(lsp, 1, 38) .. "…" or lsp + lsp = lsp:gsub("(%%)", "%1%%"):gsub("%s+", " ") --:gsub("\r", ""):gsub("\t", ""):gsub("\n", "") + return (#lsp > M.preset_width.lsp_info) and string.sub(lsp, 1, M.preset_width.lsp_info) .. "…" or lsp end return "" @@ -294,9 +293,9 @@ local function get_git_status() if signs.head ~= nil then local head = signs.head - if win_is_smaller(sl.preset_width.git_branch) then + if win_is_smaller(M.preset_width.git_branch) then return "• " - elseif win_is_smaller(sl.preset_width.git_branch, sl.preset_width.git_status_full) or no_changes then + elseif win_is_smaller(M.preset_width.git_branch, M.preset_width.git_status_full) or no_changes then return string.format(" %s ", head) else return string.format("+%s ~%s -%s |  %s ", add, change, remove, head) @@ -312,7 +311,7 @@ local function get_filetype_and_icon() local file_ext = vim.bo.filetype or vim.fn.expand "%:e" local has_icons, icons = pcall(require, "mini.icons") - local icon = sl.icons.default + local icon = M.icons.default if has_icons then icon = icons.get("filetype", file_ext) end @@ -336,14 +335,14 @@ end ---Get session name if active ---@return string session_name name of the active session or empty string local function session_name() - return sl.session_name ~= "" and " Session: " .. sl.session_name or "" + return M.session_name ~= "" and " Session: " .. M.session_name or "" end ---Get python virtual-env if is active and in python file ---@return string env_name name of python env or empty string local function get_python_env() -- if vim.bo.filetype == "python" then - if not win_is_smaller(sl.preset_width.git_branch) then + if not win_is_smaller(M.preset_width.git_branch) then local venv = os.getenv "VIRTUAL_ENV" if venv then if string.find(venv, "/") then @@ -363,8 +362,8 @@ end ---Get lsp status and if active get names of server running ---@return string lsp_status local function get_lsp_info() - return #vim.lsp.get_clients { bufnr = 0 } ~= 0 and string.format("%s• ", sl.colors.name) - or string.format("%s• ", sl.colors.lspnoactive) + return #vim.lsp.get_clients { bufnr = 0 } ~= 0 and string.format("%s• ", M.colors.name) + or string.format("%s• ", M.colors.lspnoactive) end ---Statusline disabled that display only filetype and current mode @@ -375,35 +374,35 @@ local function disable_statusline() local modifiedReadOnlyFlags = "%m%r" local special_filetypes = { - dashboard = sl.icons.dashboard .. " Dashboard", - alpha = sl.icons.dashboard .. " Dashboard", - oil = sl.icons.folder .. " File Explorer", - lazy = sl.icons.checkhealth .. " Plugin Manager", - lspinfo = sl.icons.lsp_info .. " LSP Status", - TelescopePrompt = sl.icons.telescope .. " Telescope", - qf = sl.icons.config .. " QuickFix", - toggleterm = sl.icons.robots .. "Terminal", - mason = sl.icons.list .. " Package Manager", - Outline = sl.icons.table .. " Symbols Outline", - noice = sl.icons.list .. " Notifications", - checkhealth = sl.icons.checkhealth .. " Health", - WhichKey = sl.icons.search .. " WhichKey", - query = sl.icons.query .. " Query", - dbui = sl.icons.db .. " Database", - httpResult = sl.icons.web .. " Http", - dapui_hover = sl.icons.dapui_hover .. " DapUI•Hover", - ["dap-float"] = sl.icons.dapui_watches .. " DapUI•Hover", + dashboard = M.icons.dashboard .. " Dashboard", + alpha = M.icons.dashboard .. " Dashboard", + oil = M.icons.folder .. " File Explorer", + lazy = M.icons.table .. " Plugin Manager", + lspinfo = M.icons.lsp_info .. " LSP Status", + TelescopePrompt = M.icons.telescope .. " Telescope", + qf = M.icons.config .. " QuickFix", + terminal = M.icons.robots .. "Terminal", + mason = M.icons.list .. " Package Manager", + Outline = M.icons.table .. " Symbols Outline", + noice = M.icons.list .. " Notifications", + checkhealth = M.icons.checkhealth .. " Health", + WhichKey = M.icons.search .. " WhichKey", + query = M.icons.query .. " Query", + dbui = M.icons.db .. " Database", + httpResult = M.icons.web .. " Http", + dapui_hover = M.icons.dapui_hover .. " DapUI•Hover", + ["dap-float"] = M.icons.dapui_watches .. " DapUI•Hover", } local custom_ft = special_filetypes[vim.bo.filetype] return table.concat { - sl.colors.mode, + M.colors.mode, get_mode(), modifiedReadOnlyFlags, - sl.colors.inverted, + M.colors.inverted, "", sideSep, - sl.colors.inactive, + M.colors.inactive, custom_ft or ftype_name, sideSep, } @@ -416,24 +415,26 @@ local function enable_statusline() local modifiedReadOnlyFlags = "%m%r" local space = " " - sl.cached = { + M.cached = { -- LeftSide - sl.colors.mode, + M.colors.mode, get_mode(), - sl.colors.inverted, + M.colors.inverted, "", modifiedReadOnlyFlags, space, - sl.colors.git, + M.colors.git, get_git_status(), - sl.colors.name, + M.colors.name, "%<" .. get_filename(), - sl.colors.symbols, + M.colors.symbols, "", - sl.colors.empty, + M.colors.empty, session_name(), - get_lsp_progress(), + space, get_python_env(), + space, + get_lsp_progress(), -- Middle sideSep, @@ -441,29 +442,29 @@ local function enable_statusline() space, -- Right Side - sl.colors.symbols, + M.colors.symbols, "", get_lsp_info(), - sl.colors.ftype, + M.colors.ftype, get_filetype_and_icon(), - sl.colors.encoding, + M.colors.encoding, get_fencoding(), - sl.colors.fformatloc, + M.colors.fformatloc, get_fformat(), get_line_onTot(), - sl.colors.inverted, + M.colors.inverted, "", } - return table.concat(sl.cached) + return table.concat(M.cached) end ---Set statusline based on filetype of current buffer -function sl.set() +function M.set() if not vim.g.statusline_color then set_color_groups() end - if not sl.to_exclude[vim.bo.filetype] then + if not M.to_exclude[vim.bo.filetype] then vim.wo.statusline = enable_statusline() else vim.wo.statusline = disable_statusline() @@ -471,11 +472,12 @@ function sl.set() end ---Define autocmds for load winbar module and initialize -function sl.toggle() +function M.toggle() if vim.g.statusline ~= nil then vim.api.nvim_del_autocmd(vim.g.statusline) vim.wo.statusline = "" vim.g.statusline = nil + vim.g.statusline_color = nil else vim.api.nvim_create_autocmd({ "BufNewFile", @@ -498,8 +500,16 @@ function sl.toggle() }) vim.api.nvim_eval_statusline("%!v:lua.require'lib.ui.statusline'.set()", {}) end + + vim.api.nvim_create_autocmd("ColorScheme", { + callback = function() + if vim.g.statusline ~= nil then + set_color_groups() + end + end, + }) end -vim.api.nvim_create_user_command("ToggleStatusline", sl.toggle, { desc = "Toggle Statusline" }) +vim.api.nvim_create_user_command("ToggleStatusline", M.toggle, { desc = "Toggle Statusline" }) -return sl +return M diff --git a/lua/plugins/editor/treesitter.lua b/lua/plugins/editor/treesitter.lua index aaf515c..dac52e9 100644 --- a/lua/plugins/editor/treesitter.lua +++ b/lua/plugins/editor/treesitter.lua @@ -7,7 +7,17 @@ local function parsers_to_be_installed() if vim.fn.has "mac" ~= 1 then - return {} + return { + "comment", + "json", + "java", + "groovy", + "markdown", + "markdown_inline", + "sql", + "python", + "regex", + } else return { "c", @@ -39,7 +49,6 @@ local function parsers_to_be_installed() "php", "python", "regex", - "python", "phpdoc", "scheme", "sql", @@ -155,4 +164,4 @@ return { }, "nvim-treesitter/nvim-treesitter-refactor", -} +} \ No newline at end of file diff --git a/lua/plugins/ui/dashboard.lua b/lua/plugins/ui/dashboard.lua index 77fd29e..44c0cac 100644 --- a/lua/plugins/ui/dashboard.lua +++ b/lua/plugins/ui/dashboard.lua @@ -85,7 +85,7 @@ return { db_btn("f", "󰾰 Find file", "lua require 'lib'.find_files()"), db_btn("r", " Recent files", "lua require 'lib'.recent_files()"), - db_btn("R", " Find project", "lua require 'lib'.projects()"), + db_btn("p", " Find project", "lua require 'lib'.projects()"), db_btn("d", "󰾰 Developer", [[lua require "lib".dev_folder()]]), db_btn("L", " Plugin Manager", "Lazy"), db_btn("m", " Package Manager", "Mason"), diff --git a/plugin/autocommands.lua b/plugin/autocommands.lua index 8d1d69a..1ee776f 100644 --- a/plugin/autocommands.lua +++ b/plugin/autocommands.lua @@ -98,22 +98,6 @@ autocmd("FileType", { end, }) ----QuickFixList keymaps -autocmd("FileType", { - group = augroup("_maps_qf_ft", { clear = true }), - pattern = "qf", - callback = function() - vim.keymap.set("n", "", "cprev", { buffer = true, silent = true }) - vim.keymap.set("n", "", "cnext", { buffer = true, silent = true }) - vim.keymap.set("n", "", "", { buffer = true, silent = true }) - vim.keymap.set("n", "q", function() - vim.cmd.quit { bang = true } - end, { buffer = true, silent = true }) - vim.keymap.set("n", "", function() - vim.cmd.quit { bang = true } - end, { buffer = true, silent = true }) - end, -}) autocmd("FileType", { group = augroup("_autocmd_statuscolumn", { clear = true }), @@ -143,38 +127,38 @@ autocmd({ "BufNewFile", "BufRead" }, { ---Check if want to install Treesitter parser for current ---filetype if missing -autocmd("FileType", { - group = augroup("_check_ft_ts_parser", { clear = true }), - pattern = "*", - callback = function(ev) - if not filetypes_to_exclude[ev.match] then - local has_ts, ts_parsers = pcall(require, "nvim-treesitter.parsers") - if not has_ts then - return - end - - local lang = ts_parsers.get_buf_lang() - local donot_ask_install = vim.g.dont_ask_install or {} - if - ts_parsers.get_parser_configs()[lang] - and not ts_parsers.has_parser(lang) - and not donot_ask_install[lang] == true - then - vim.schedule_wrap(function() - local msg = string.format("Install missing TS parser for < %s >?", lang) - local choice = vim.fn.confirm(msg, "&Yes\n&No") - - if choice == 1 then - vim.cmd.TSInstall(lang) - else - donot_ask_install[lang] = true - vim.g.dont_ask_install = donot_ask_install - end - end)() - end - end - end, -}) +-- autocmd("FileType", { +-- group = augroup("_check_ft_ts_parser", { clear = true }), +-- pattern = "*", +-- callback = function(ev) +-- if not filetypes_to_exclude[ev.match] then +-- local has_ts, ts_parsers = pcall(require, "nvim-treesitter.parsers") +-- if not has_ts then +-- return +-- end +-- +-- local lang = ts_parsers.get_buf_lang() +-- local donot_ask_install = vim.g.dont_ask_install or {} +-- if +-- ts_parsers.get_parser_configs()[lang] +-- and not ts_parsers.has_parser(lang) +-- and not donot_ask_install[lang] == true +-- then +-- vim.schedule_wrap(function() +-- local msg = string.format("Install missing TS parser for < %s >?", lang) +-- local choice = vim.fn.confirm(msg, "&Yes\n&No") +-- +-- if choice == 1 then +-- vim.cmd.TSInstall(lang) +-- else +-- donot_ask_install[lang] = true +-- vim.g.dont_ask_install = donot_ask_install +-- end +-- end)() +-- end +-- end +-- end, +-- }) ---Set makeprg and keywordprg for filetype (using default compiler when available) -- autocmd("FileType", { @@ -206,10 +190,9 @@ autocmd("BufRead", { ---Insert mode on builtin Neovim terminal autocmd("TermOpen", { group = augroup("_startinsert_term_open", { clear = true }), - callback = function() + callback = function(ev) vim.cmd.startinsert() - vim.opt_local.number = false - vim.opt_local.relativenumber = false + vim.bo[ev.buf].filetype = "terminal" end, }) @@ -259,29 +242,6 @@ autocmd({ "BufRead", "BufNewFile" }, { end, }) ----Start postgresql service on sql files --- autocmd("FileType", { --- group = augroup("_postres_service", { clear = true }), --- pattern = { "sql" }, --- once = true, -- don't run again on other sql files --- callback = function() --- require("lib").run_brew_service("postgresql@14", false) --- end, --- }) - ----Read PDF into neovim, using pdftotext binary -autocmd("FileType", { - group = augroup("_pdf_reader", { clear = true }), - pattern = { "pdf", "PDF" }, - callback = function(ev) - vim.api.nvim_set_option_value("readonly", true, { buf = ev.buf }) - if not vim.fn.executable "pdftotext" then - vim.notify("vim-pdf: pdftotext is not found.\nStop converting...", vim.log.levels.ERROR) - return - end - require("lib.pdf").load_pdf(ev.file) - end, -}) ---Hex autocmd("FileType", { diff --git a/plugin/prefs.lua b/plugin/prefs.lua index be4ed6e..8a241ed 100644 --- a/plugin/prefs.lua +++ b/plugin/prefs.lua @@ -99,6 +99,14 @@ local settings = { -- SPELL spelllang = "it,en_us", spelloptions = "camel", + + -- POWERSHELL + shell = vim.fn.executable('pwsh') == 1 and 'pwsh' or 'powershell', + shellcmdflag = '-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues[\'Out-File:Encoding\']=\'utf8\';', + shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode', + shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode', + shellquote = '', + shellxquote = '', } for k, o in pairs(settings) do diff --git a/plugin/usercommands.lua b/plugin/usercommands.lua index 642aba1..c90c15e 100644 --- a/plugin/usercommands.lua +++ b/plugin/usercommands.lua @@ -57,12 +57,12 @@ user_command("WipeReg", function() end, { desc = "Wipe all Registers" }) ---Sessions -user_command("Session", function(arg) +vim.api.nvim_create_user_command("Session", function(arg) require("lib.session").select(arg.args) end, { - nargs = 1, + nargs = "?", desc = "Session Manager", - complete = "custom,v:lua.require'lib.session'.usercmd_session_completion", + -- complete = "custom,v:lua.require'lib.session'.usercmd_session_completion", }) ---Config File diff --git a/snippets/general/java/java.json b/snippets/general/java/java.json index 4fab715..def8769 100644 --- a/snippets/general/java/java.json +++ b/snippets/general/java/java.json @@ -1,165 +1,157 @@ { - "main": { - "prefix": "main", - "body": ["public static void main(String[] args) {", "\t$0", "}"], - "description": "Public static main method" - }, - "class": { - "prefix": "class", - "body": ["public class ${TM_FILENAME_BASE} {", "\t$0", "}"], - "description": "Public class" - }, - "sysout": { - "prefix": "sysout", - "body": ["System.out.println($0);"], - "description": "Print to standard out" - }, - "syserr": { - "prefix": "syserr", - "body": ["System.err.println($0);"], - "description": "Print to standard err" - }, - "fori": { - "prefix": "fori", - "body": [ - "for (${1:int} ${2:i} = ${3:0}; $2 < ${4:max}; $2++) {", - "\t$0", - "}" - ], - "description": "Indexed for loop" - }, - "foreach": { - "prefix": "foreach", - "body": ["for (${1:type} ${2:var} : ${3:iterable}) {", "\t$0", "}"], - "description": "Enhanced for loop" - }, - "Public constructor": { - "prefix": "ctor", - "body": [ - "public ${1:${TM_FILENAME_BASE}}($2) {", - "\t${0:super();}", - "}" - ], - "description": "Public constructor" - }, - "if": { - "prefix": "if", - "body": ["if (${1:condition}) {", "\t$0", "}"], - "description": "if statement" - }, - "ifelse": { - "prefix": "ifelse", - "body": ["if (${1:condition}) {", "\t$2", "} else {", "\t$0", "}"], - "description": "if/else statement" - }, - "ifnull": { - "prefix": "ifnull", - "body": ["if (${1:condition} == null) {", "\t$0", "}"], - "description": "if statement checking for null" - }, - "ifnotnull": { - "prefix": "ifnotnull", - "body": ["if (${1:condition} != null) {", "\t$0", "}"], - "description": "if statement checking for not null" - }, - "trycatch": { - "prefix": "try_catch", - "body": [ - "try {", - "\t$1", - "} catch (${2:Exception} ${3:e}) {", - "\t$4//${0:TODO}: handle exception", - "}" - ], - "description": "try/catch block" - }, - "tryresources": { - "prefix": "try_resources", - "body": [ - "try ($1) {", - "\t$2", - "} catch (${3:Exception} ${4:e}) {", - "\t$5//${0:TODO}: handle exception", - "}" - ] - }, - "private_method": { - "prefix": "private_method", - "body": ["private ${1:void} ${2:name}($3) {", "\t$0", "}"], - "description": "private method" - }, - "Public method": { - "prefix": "public_method", - "body": ["public ${1:void} ${2:name}(${3}) {", "\t$0", "}"], - "description": "public method" - }, - "Private static method": { - "prefix": "private_static_method", - "body": ["private static ${1:Type} ${2:name}(${3}) {", "\t$0", "}"], - "description": "private static method" - }, - "Public static method": { - "prefix": "public_static_method", - "body": ["public static ${1:void} ${2:name}(${3}) {", "\t$0", "}"], - "description": "public static method" - }, - "Protected Method": { - "prefix": "protected_method", - "body": ["protected ${1:void} ${2:name}(${3}) {", "\t$0", "}"], - "description": "Protected method" - }, - "Switch Statement": { - "prefix": "switch", - "body": [ - "switch (${1:key}) {", - "\tcase ${2:value}:", - "\t\t$0", - "\t\tbreak;", - "", - "\tdefault:", - "\t\tbreak;", - "}" - ], - "description": "Switch Statement" - }, - "While Statement": { - "prefix": "while", - "body": ["while (${1:condition}) {", "\t$0", "}"], - "description": "While Statement" - }, - "Do-While Statement": { - "prefix": "dowhile", - "body": ["do {", "\t$0", "} while (${1:condition});"], - "description": "Do-While Statement" - }, - "newObject": { - "prefix": "new", - "body": ["${1:Object} ${2:foo} = new ${1:Object}();"], - "description": "Create new Object" - }, - "Public field": { - "prefix": "public_field", - "body": ["public ${1:String} ${2:name};"], - "description": "Public field" - }, - "Private field": { - "prefix": "private_field", - "body": ["private ${1:String} ${2:name};"], - "description": "Private field" - }, - "Protected field": { - "prefix": "protected_field", - "body": ["protected ${1:String} ${2:name};"], - "description": "Protected field" - }, - "package": { - "prefix": "package", - "body": ["package ${1:PackageName}"], - "description": "Package statement" - }, - "import": { - "prefix": "import", - "body": ["import ${1:PackageName}"], - "description": "Import statement" - } + "main": { + "prefix": "main", + "body": ["public static void main(String[] args) {", "\t$0", "}"], + "description": "Public static main method" + }, + "class": { + "prefix": "class", + "body": ["public class ${TM_FILENAME_BASE} {", "\t$0", "}"], + "description": "Public class" + }, + "sysout": { + "prefix": "sysout", + "body": ["System.out.println($0);"], + "description": "Print to standard out" + }, + "syserr": { + "prefix": "syserr", + "body": ["System.err.println($0);"], + "description": "Print to standard err" + }, + "fori": { + "prefix": "fori", + "body": ["for (${1:int} ${2:i} = ${3:0}; $2 < ${4:max}; $2++) {", "\t$0", "}"], + "description": "Indexed for loop" + }, + "foreach": { + "prefix": "foreach", + "body": ["for (${1:type} ${2:var} : ${3:iterable}) {", "\t$0", "}"], + "description": "Enhanced for loop" + }, + "Public constructor": { + "prefix": "ctor", + "body": ["public ${1:${TM_FILENAME_BASE}}($2) {", "\t${0:super();}", "}"], + "description": "Public constructor" + }, + "if": { + "prefix": "if", + "body": ["if (${1:condition}) {", "\t$0", "}"], + "description": "if statement" + }, + "ifelse": { + "prefix": "ifelse", + "body": ["if (${1:condition}) {", "\t$2", "} else {", "\t$0", "}"], + "description": "if/else statement" + }, + "ifnull": { + "prefix": "ifnull", + "body": ["if (${1:condition} == null) {", "\t$0", "}"], + "description": "if statement checking for null" + }, + "ifnotnull": { + "prefix": "ifnotnull", + "body": ["if (${1:condition} != null) {", "\t$0", "}"], + "description": "if statement checking for not null" + }, + "trycatch": { + "prefix": "try_catch", + "body": [ + "try {", + "\t$1", + "} catch (${2:Exception} ${3:e}) {", + "\t$4//${0:TODO}: handle exception", + "}" + ], + "description": "try/catch block" + }, + "tryresources": { + "prefix": "try_resources", + "body": [ + "try ($1) {", + "\t$2", + "} catch (${3:Exception} ${4:e}) {", + "\t$5//${0:TODO}: handle exception", + "}" + ] + }, + "private_method": { + "prefix": "private_method", + "body": ["private ${1:void} ${2:name}($3) {", "\t$0", "}"], + "description": "private method" + }, + "Public method": { + "prefix": "public_method", + "body": ["public ${1:void} ${2:name}(${3}) {", "\t$0", "}"], + "description": "public method" + }, + "Private static method": { + "prefix": "private_static_method", + "body": ["private static ${1:Type} ${2:name}(${3}) {", "\t$0", "}"], + "description": "private static method" + }, + "Public static method": { + "prefix": "public_static_method", + "body": ["public static ${1:void} ${2:name}(${3}) {", "\t$0", "}"], + "description": "public static method" + }, + "Protected Method": { + "prefix": "protected_method", + "body": ["protected ${1:void} ${2:name}(${3}) {", "\t$0", "}"], + "description": "Protected method" + }, + "Switch Statement": { + "prefix": "switch", + "body": [ + "switch (${1:key}) {", + "\tcase ${2:value}:", + "\t\t$0", + "\t\tbreak;", + "", + "\tdefault:", + "\t\tbreak;", + "}" + ], + "description": "Switch Statement" + }, + "While Statement": { + "prefix": "while", + "body": ["while (${1:condition}) {", "\t$0", "}"], + "description": "While Statement" + }, + "Do-While Statement": { + "prefix": "dowhile", + "body": ["do {", "\t$0", "} while (${1:condition});"], + "description": "Do-While Statement" + }, + "newObject": { + "prefix": "new", + "body": ["${1:Object} ${2:foo} = new ${1:Object}();"], + "description": "Create new Object" + }, + "Public field": { + "prefix": "public_field", + "body": ["public ${1:String} ${2:name};"], + "description": "Public field" + }, + "Private field": { + "prefix": "private_field", + "body": ["private ${1:String} ${2:name};"], + "description": "Private field" + }, + "Protected field": { + "prefix": "protected_field", + "body": ["protected ${1:String} ${2:name};"], + "description": "Protected field" + }, + "package": { + "prefix": "package", + "body": ["package ${1:PackageName}"], + "description": "Package statement" + }, + "import": { + "prefix": "import", + "body": ["import ${1:PackageName}"], + "description": "Import statement" + } } diff --git a/snippets/general/xsl.json b/snippets/general/xsl.json index cde26ce..f2baae5 100644 --- a/snippets/general/xsl.json +++ b/snippets/general/xsl.json @@ -30,7 +30,7 @@ "\t\t", "\t", "\t", - "\t\t", + "\t\t", "\t", "" ], @@ -48,4 +48,3 @@ "description": "xsl if statement" } } -