diff --git a/init.lua b/init.lua index b3edd19..cf284c3 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,4 @@ +-- Begin NvChad setup vim.g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" vim.g.mapleader = " " @@ -38,6 +39,8 @@ vim.schedule(function() local mappings = require "mappings" mappings.General() end) +-- end NvChad setup + local autocmd = vim.api.nvim_create_autocmd -- Auto resize panes when resizing nvim window @@ -45,64 +48,28 @@ autocmd("VimResized", { pattern = "*", command = "tabdo wincmd =", }) --- if windows or WSL -if vim.loop.os_uname() == "win32" then - vim.g.clipboard = { - name = "WslClipboard", - copy = { - ["+"] = "clip.exe", - ["*"] = "clip.exe", - }, - paste = { - ["+"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', - ["*"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', - }, - cache_enabled = 0, - } - -- if nvim supports osc52 -elseif pcall(require, "vim.ui.clipboard.osc52") then - vim.g.clipboard = { - name = "OSC 52", - copy = { - ["+"] = require("vim.ui.clipboard.osc52").copy, - ["*"] = require("vim.ui.clipboard.osc52").copy, - }, - paste = { - ["+"] = require("vim.ui.clipboard.osc52").paste, - ["*"] = require("vim.ui.clipboard.osc52").paste, - }, - } - -- use osc52 plugin -elseif pcall(require, "osc52") then - local function copy(lines, _) - require("osc52").copy(table.concat(lines, "\n")) - end - - local function paste() - return { vim.fn.split(vim.fn.getreg "", "\n"), vim.fn.getregtype "" } - end - - vim.g.clipboard = { - name = "osc52", - copy = { ["+"] = copy, ["*"] = copy }, - paste = { ["+"] = paste, ["*"] = paste }, - } -end -vim.opt.relativenumber = true -vim.opt.cursorline = true +-- Set default shell to pwsh on windows if vim.loop.os_uname() == "win32" then vim.opt.shell = vim.fn.executable "pwsh" == 1 and "pwsh" or "powershell" vim.opt.shellcmdflag = - "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;" + "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;" vim.opt.shellredir = "-RedirectStandardOutput %s -NoNewWindow -Wait" vim.opt.shellpipe = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode" vim.opt.shellquote = "" vim.opt.shellxquote = "" else - vim.opt.shell = vim.fn.executable "zsh" == 1 and "zsh" or "bash" + -- vim.opt.shell = env.SHELL end + +vim.opt.relativenumber = true +vim.opt.cursorline = true vim.g.copilot_assume_mapped = true -vim.opt.foldmethod = "expr" -vim.opt.foldexpr = "nvim_treesitter#foldexpr()" -vim.opt.foldenable = false +-- ufo config +vim.o.foldcolumn = "0" -- '0' is not bad +vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +vim.o.foldlevelstart = 99 +-- vim.o.foldenable = true +vim.opt.wildmode = { "list", "longest" } +vim.opt.wildmenu = true +vim.opt.autoread = true diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 87c6325..121a700 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -5,21 +5,15 @@ local M = {} local highlights = require "highlights" M.ui = { theme = "lunar_witch", - -- theme_toggle = { "onedark", "one_light" }, hl_override = highlights.override, hl_add = highlights.add, statusline = { - overriden_modules = function (modules) + overriden_modules = function(modules) modules[10] = vim.o.columns > 140 and "%#StText# [%l,%c]" or "" - end - } + end, + }, } --- M.plugins = "plugins" - --- check core.mappings for table structure --- M.mappings = require "mappings" - return M diff --git a/lua/configs/lazy.lua b/lua/configs/lazy.lua index cd170bd..9ac955f 100644 --- a/lua/configs/lazy.lua +++ b/lua/configs/lazy.lua @@ -1,6 +1,5 @@ return { defaults = { lazy = true }, - install = { colorscheme = { "nvchad" } }, ui = { icons = { diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index c95b100..15294be 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -1,5 +1,6 @@ local lspconfig = require "lspconfig" local on_attach = require("nvchad.configs.lspconfig").on_attach +local on_attach = require("nvchad.configs.lspconfig").on_init local capabilities = require("nvchad.configs.lspconfig").capabilities -- if you just want default config for the servers then put them in a table @@ -20,38 +21,9 @@ local servers = { for _, lsp in ipairs(servers) do lspconfig[lsp].setup { on_attach = on_attach, + on_init = on_init, capabilities = capabilities, } end -lspconfig.lua_ls.setup { - on_init = function(client) - local path = client.workspace_folders[1].name - if not vim.loop.fs_stat(path .. "/.luarc.json") and not vim.loop.fs_stat(path .. "/.luarc.jsonc") then - client.config.settings = vim.tbl_deep_extend("force", client.config.settings, { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using - -- (most likely LuaJIT in the case of Neovim) - version = "LuaJIT", - }, - -- Make the server aware of Neovim runtime files - workspace = { - checkThirdParty = false, - library = { - vim.env.VIMRUNTIME, - -- "${3rd}/luv/library" - -- "${3rd}/busted/library", - }, - -- or pull in all of 'runtimepath'. NOTE: this is a lot slower - -- library = vim.api.nvim_get_runtime_file("", true) - }, - }, - }) - client.notify("workspace/didChangeConfiguration", { settings = client.config.settings }) - end - return true - end, -} - require("copilot").setup() diff --git a/lua/configs/overrides.lua b/lua/configs/overrides.lua index 57baab4..44cc4e8 100644 --- a/lua/configs/overrides.lua +++ b/lua/configs/overrides.lua @@ -56,9 +56,6 @@ M.nvimtree = { }, } M.copilot = { - config = function(_, opts) - require("core.utils").load_mappings "copilot" - end, suggestion = { auto_trigger = true, }, diff --git a/lua/highlights.lua b/lua/highlights.lua index 260e9d2..d73a44a 100644 --- a/lua/highlights.lua +++ b/lua/highlights.lua @@ -6,7 +6,9 @@ local M = {} ---@type Base46HLGroupsList M.override = { Comment = { + fg = "grey_fg", italic = true, + bold = true, }, St_NormalMode = { fg = "white", @@ -29,6 +31,20 @@ M.add = { NvimTreeSpecialFile = { fg = "yellow", }, + ["@comment"] = { + fg = "grey_fg", + italic = true, + bold = true, + }, + Type = { + fg = "yellow", + }, + ["@type"] = { + fg = "yellow", + }, + Structure = { + fg = "yellow", + }, } return M diff --git a/lua/mappings.lua b/lua/mappings.lua index b272d70..7a108a5 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -4,11 +4,32 @@ local M = {} M.General = function() map("n", ";", ":", { desc = "general enter command mode", nowait = true }) map("v", ">", ">gv", { desc = "general indent" }) - map("n", "", "h", { desc = "general Window left" }) - map("n", "", "l", { desc = "general Window right" }) - map("n", "", "j", { desc = "general Window down" }) - map("n", "", "k", { desc = "general Window up" }) + map("n", "", "h", { desc = "switch Window left" }) + map("n", "", "l", { desc = "switch Window right" }) + map("n", "", "j", { desc = "switch Window down" }) + map("n", "", "k", { desc = "switch Window up" }) + map("n", "K", "Lspsaga hover_doc", { desc = "LSPSaga Hover" }) + map("n", "]d", function() + vim.diagnostic.goto_next() + end, { desc = "LSP Next Diagnostic" }) + map("n", "[d", function() + vim.diagnostic.goto_prev() + end, { desc = "LSP Prev Diagnostic" }) + map("n", "lf", "Lspsaga show_cursor_diagnostics", { desc = "LSPSaga floating diagnostic" }) + map("n", "gr", "Lspsaga finder ref", { desc = "LSPSaga search references" }) + map("n", "gi", "Lspsaga finder imp", { desc = "LSPSaga search implementation" }) + map("n", "gd", "Lspsaga finder def", { desc = "LSPSaga search definition" }) + map("n", "rr", "Lspsaga rename", { desc = "LSPSaga rename" }) + map("n", "ci", "Lspsaga incoming_calls", { desc = "LSPSaga incoming calls" }) + map("n", "co", "Lspsaga outgoing_calls", { desc = "LSPSaga outgoing calls" }) + map("n", "", "Lspsaga outline", { desc = "LSPSaga outline" }) end + +M.Ufo = function() + map("n", "zR", require("ufo").openAllFolds, { desc = "UFO Open All Folds" }) + map("n", "zM", require("ufo").closeAllFolds, { desc = "UFO Close All Folds" }) +end + M.Dap = function() map("n", "db", " DapToggleBreakpoint ", { desc = "dap Toggle Breakpoint" }) map("n", "dus", function() diff --git a/lua/plugins/init.lua b/lua/plugins.lua similarity index 83% rename from lua/plugins/init.lua rename to lua/plugins.lua index f9568fa..e856f7f 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins.lua @@ -26,7 +26,7 @@ return { -- "deno", "prettier", - -- c/cpp slike he has tuff + -- c/cpp stuff "clangd", "clang-format", @@ -41,6 +41,23 @@ return { }, }, }, + -- { + -- "cbochs/grapple.nvim", + -- dependencies = { + -- { "nvim-tree/nvim-web-devicons", lazy = true }, + -- }, + -- lazy = false, + -- }, + { + "nvimdev/lspsaga.nvim", + config = function() + require("lspsaga").setup {} + end, + dependencies = { + "nvim-treesitter/nvim-treesitter", -- optional + "nvim-tree/nvim-web-devicons", -- optional + }, + }, { "ThePrimeagen/refactoring.nvim" }, { "nvimtools/none-ls.nvim", @@ -56,6 +73,9 @@ return { require "nvchad.configs.lspconfig" require "configs.lspconfig" end, -- Override to setup mason-lspconfig + dependencies = { + "nvimdev/lspsaga.nvim", + }, lazy = false, }, @@ -86,7 +106,7 @@ return { }, -- Delimiters - { "Raimondi/delimitMate", lazy = false }, + { "Raimondi/delimitMate", lazy = false }, -- lazygit { "kdheepak/lazygit.nvim", @@ -96,7 +116,7 @@ return { lazy = false, }, -- fzf - { "junegunn/fzf.vim", lazy = false }, + { "junegunn/fzf.vim", lazy = false }, { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim", "junegunn/fzf.vim" }, @@ -129,7 +149,6 @@ return { opts = overrides.nvimtree, }, - -- Install a plugin { "max397574/better-escape.nvim", event = "InsertEnter", @@ -138,30 +157,7 @@ return { end, }, - -- TODO: remove this on nvim 0.10 - { - "ojroques/nvim-osc52", - config = function() - local function copy(lines, _) - require("osc52").copy(table.concat(lines, "\n")) - end - - local function paste() - return { vim.fn.split(vim.fn.getreg "", "\n"), vim.fn.getregtype "" } - end - - vim.g.clipboard = { - name = "osc52", - copy = { ["+"] = copy, ["*"] = copy }, - paste = { ["+"] = paste, ["*"] = paste }, - } - - -- Now the '+' register will copy to system clipboard using OSC52 - -- vim.keymap.set('n', 'c', '"+y') - -- vim.keymap.set('n', 'cc', '"+yy') - end, - }, - { "zbirenbaum/copilot.lua", event = "InsertEnter", opts = overrides.copilot, lazy = false }, + { "zbirenbaum/copilot.lua", event = "InsertEnter", lazy = false }, -- Nyoom around files { "smoka7/hop.nvim", @@ -172,6 +168,19 @@ return { print(mappings.Hop()) end, }, + { + "kevinhwang91/nvim-ufo", + dependencies = { "kevinhwang91/promise-async" }, + config = function() + require("ufo").setup { + provider_selector = function(bufnr, filetype, buftype) + return { "treesitter", "indent" } + end, + } + mappings.Ufo() + end, + lazy = false, + }, ------------ -- Python -- @@ -211,17 +220,6 @@ return { vim.g.rustfmt_autosave = 1 end, }, - { - "simrat39/rust-tools.nvim", - ft = "rust", - dependencies = "neovim/nvim-lspconfig", - opts = function() - return require "configs.rust-tools" - end, - config = function(_, opts) - require("rust-tools").setup(opts) - end, - }, { "saecki/crates.nvim", ft = { "rust", "toml" },