diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index cfd3ef9..efd91b2 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -19,3 +19,5 @@ require("user.indentline") require("user.alpha") require("user.whichkey") require("user.trouble") +require("user.colorizer") +require("user.gps") diff --git a/.config/nvim/lua/user/autocommands.lua b/.config/nvim/lua/user/autocommands.lua new file mode 100644 index 0000000..d31bf83 --- /dev/null +++ b/.config/nvim/lua/user/autocommands.lua @@ -0,0 +1,46 @@ +-- Use 'q' to quit from common plugins +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "qf", "help", "man", "lspinfo", "spectre_panel", "lir" }, + callback = function() + vim.cmd([[ + nnoremap q :close + set nobuflisted + ]]) + end, +}) + +-- Remove statusline and tabline when in Alpha +vim.api.nvim_create_autocmd({ "User" }, { + pattern = { "AlphaReady" }, + callback = function() + vim.cmd([[ + set showtabline=0 | autocmd BufUnload set showtabline=2 + set laststatus=0 | autocmd BufUnload set laststatus=3 + ]]) + end, +}) + +-- Set wrap and spell in markdown and gitcommit +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif") + +-- Fixes Autocomment +vim.api.nvim_create_autocmd({ "BufWinEnter" }, { + callback = function() + vim.cmd("set formatoptions-=cro") + end, +}) + +-- Highlight Yanked Text +vim.api.nvim_create_autocmd({ "TextYankPost" }, { + callback = function() + vim.highlight.on_yank({ higroup = "Visual", timeout = 200 }) + end, +}) diff --git a/.config/nvim/lua/user/autopairs.lua b/.config/nvim/lua/user/autopairs.lua index b849633..2cf6873 100644 --- a/.config/nvim/lua/user/autopairs.lua +++ b/.config/nvim/lua/user/autopairs.lua @@ -1,25 +1,12 @@ +-- Setup nvim-cmp. local status_ok, npairs = pcall(require, "nvim-autopairs") if not status_ok then return end npairs.setup({ - check_ts = true, - ts_config = { - lua = { "string", "source" }, - }, + check_ts = true, -- treesitter integration disable_filetype = { "TelescopePrompt" }, - fast_wrap = { - map = "", - chars = { "{", "[", "(", '"', "'" }, - pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), - offset = 0, - end_key = "$", - keys = "qwertyuiopzxcvbnmasdfghjkl", - check_comma = true, - highlight = "PmenuSel", - highlight_grey = "LineNr", - }, }) local cmp_autopairs = require("nvim-autopairs.completion.cmp") @@ -27,4 +14,4 @@ local cmp_status_ok, cmp = pcall(require, "cmp") if not cmp_status_ok then return end -cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({})) diff --git a/.config/nvim/lua/user/cmp.lua b/.config/nvim/lua/user/cmp.lua index fbc0b1f..080cca8 100644 --- a/.config/nvim/lua/user/cmp.lua +++ b/.config/nvim/lua/user/cmp.lua @@ -115,8 +115,10 @@ cmp.setup({ behavior = cmp.ConfirmBehavior.Replace, select = false, }, - documentation = { - border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + window = { + documentation = { + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + }, }, experimental = { ghost_text = true, diff --git a/.config/nvim/lua/user/colorizer.lua b/.config/nvim/lua/user/colorizer.lua new file mode 100644 index 0000000..875aa13 --- /dev/null +++ b/.config/nvim/lua/user/colorizer.lua @@ -0,0 +1,17 @@ +local status_ok, colorizer = pcall(require, "colorizer") +if not status_ok then + return +end + +colorizer.setup({ "*" }, { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = false, -- "Name" codes like Blue oe blue + RRGGBBAA = true, -- #RRGGBBAA hex codes + rgb_fn = true, -- CSS rgb() and rgba() functions + hsl_fn = true, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes: foreground, background, virtualtext + mode = "background", -- Set the display mode.) +}) diff --git a/.config/nvim/lua/user/gps.lua b/.config/nvim/lua/user/gps.lua new file mode 100644 index 0000000..98190b2 --- /dev/null +++ b/.config/nvim/lua/user/gps.lua @@ -0,0 +1,34 @@ +local status_ok, gps = pcall(require, "nvim-gps") +if not status_ok then + return +end + +gps.setup({ + disable_icons = false, -- Setting it to true will disable all icons + icons = { + ["class-name"] = " ", -- Classes and class-like objects + ["function-name"] = " ", -- Functions + ["method-name"] = " ", -- Methods (functions inside class-like objects) + ["container-name"] = "⛶ ", -- Containers (example: lua tables) + ["tag-name"] = "炙 ", -- Tags (example: html tags) + ["mapping-name"] = " ", + ["sequence-name"] = " ", + ["null-name"] = "[] ", + ["boolean-name"] = "ﰰﰴ ", + ["integer-name"] = "# ", + ["float-name"] = " ", + ["string-name"] = " ", + ["array-name"] = " ", + ["object-name"] = " ", + ["number-name"] = "# ", + ["table-name"] = " ", + ["date-name"] = " ", + ["date-time-name"] = " ", + ["inline-table-name"] = " ", + ["time-name"] = " ", + ["module-name"] = " ", + }, + separator = " > ", + depth = 0, + depth_limit_indicator = "..", +}) diff --git a/.config/nvim/lua/user/illuminate.lua b/.config/nvim/lua/user/illuminate.lua new file mode 100644 index 0000000..862843e --- /dev/null +++ b/.config/nvim/lua/user/illuminate.lua @@ -0,0 +1,3 @@ +vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree'} +vim.api.nvim_set_keymap('n', '', 'lua require"illuminate".next_reference{wrap=true}', {noremap=true}) +vim.api.nvim_set_keymap('n', '', 'lua require"illuminate".next_reference{reverse=true,wrap=true}', {noremap=true}) diff --git a/.config/nvim/lua/user/lsp/handlers.lua b/.config/nvim/lua/user/lsp/handlers.lua index 58ec079..ee0fca2 100644 --- a/.config/nvim/lua/user/lsp/handlers.lua +++ b/.config/nvim/lua/user/lsp/handlers.lua @@ -42,18 +42,11 @@ M.setup = function() end local function lsp_highlight_document(client) - if client.resolved_capabilities.document_highlight then - vim.api.nvim_exec( - [[ - augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]], - false - ) + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return end + illuminate.on_attach(client) end local function lsp_keymaps(bufnr) diff --git a/.config/nvim/lua/user/lsp/nullls.lua b/.config/nvim/lua/user/lsp/nullls.lua index 5fd6114..43e356a 100644 --- a/.config/nvim/lua/user/lsp/nullls.lua +++ b/.config/nvim/lua/user/lsp/nullls.lua @@ -12,11 +12,11 @@ null_ls.setup({ formatting.stylua, }, on_attach = function(client) - if client.resolved_capabilities.document_formatting then + if client.server_capabilities.documentFormattingProvider then vim.cmd([[ augroup LspFormatting autocmd! * - autocmd BufWritePre lua vim.lsp.buf.formatting_sync() + autocmd BufWritePre lua vim.lsp.buf.format() augroup END ]]) end diff --git a/.config/nvim/lua/user/lualine.lua b/.config/nvim/lua/user/lualine.lua index 8ef6751..21bbc57 100644 --- a/.config/nvim/lua/user/lualine.lua +++ b/.config/nvim/lua/user/lualine.lua @@ -3,6 +3,20 @@ if not status_ok then return end +local status_gps_ok, gps = pcall(require, "nvim-gps") +if not status_gps_ok then + return +end + +local nvim_gps = function() + local gps_location = gps.get_location() + if gps_location == "error" then + return "" + else + return gps.get_location() + end +end + lualine.setup({ options = { icons_enabled = true, @@ -15,7 +29,7 @@ lualine.setup({ sections = { lualine_a = { "mode" }, lualine_b = { "branch", "diff", "diagnostics" }, - lualine_c = { "filename", "filesize" }, + lualine_c = { "filename", "filesize", nvim_gps }, lualine_x = { "encoding", "fileformat", "filetype" }, lualine_y = { "progress" }, lualine_z = { "location" }, diff --git a/.config/nvim/lua/user/nvimtree.lua b/.config/nvim/lua/user/nvimtree.lua index c738646..3174b8f 100644 --- a/.config/nvim/lua/user/nvimtree.lua +++ b/.config/nvim/lua/user/nvimtree.lua @@ -1,24 +1,3 @@ -vim.g.nvim_tree_icons = { - default = "", - symlink = "", - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - deleted = "", - untracked = "U", - ignored = "◌", - }, - folder = { - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - }, -} - local status_ok, nvim_tree = pcall(require, "nvim-tree") if not status_ok then return @@ -30,6 +9,14 @@ if not config_status_ok then end local tree_cb = nvim_tree_config.nvim_tree_callback +vim.api.nvim_create_autocmd("BufEnter", { + nested = true, + callback = function() + if #vim.api.nvim_list_wins() == 1 and vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil then + vim.cmd("quit") + end + end, +}) nvim_tree.setup({ disable_netrw = true, @@ -38,14 +25,9 @@ nvim_tree.setup({ ignore_ft_on_setup = { "alpha", }, - auto_close = true, open_on_tab = false, hijack_cursor = true, update_cwd = true, - update_to_buf_dir = { - enable = true, - auto_open = true, - }, diagnostics = { enable = true, icons = { @@ -82,15 +64,40 @@ nvim_tree.setup({ number = false, relativenumber = false, }, - quit_on_open = 0, - git_hl = 1, - disable_window_picker = 0, - root_folder_modifier = ":t", - show_icons = { - git = 1, - folders = 1, - files = 1, - folder_arrows = 1, - tree_width = 30, + actions = { + open_file = { + quit_on_open = false, + window_picker = { + enable = false, + }, + }, + }, + renderer = { + icons = { + glyphs = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, + }, + }, + }, + filesystem_watchers = { + enable = true, + interval = 100, }, }) diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/user/plugins.lua index 251aa22..c0a8de9 100644 --- a/.config/nvim/lua/user/plugins.lua +++ b/.config/nvim/lua/user/plugins.lua @@ -119,6 +119,15 @@ return packer.startup(function(use) -- WhichKey use("folke/which-key.nvim") + -- Illuminate + use("RRethy/vim-illuminate") + + -- Colorizer + use("norcalli/nvim-colorizer.lua") + + -- GPS + use("SmiteshP/nvim-gps") + if PACKER_BOOTSTRAP then require("packer").sync() end diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua index 54b182c..eee2ef6 100644 --- a/.config/nvim/plugin/packer_compiled.lua +++ b/.config/nvim/plugin/packer_compiled.lua @@ -169,6 +169,16 @@ _G.packer_plugins = { path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-cmp", url = "https://github.com/hrsh7th/nvim-cmp" }, + ["nvim-colorizer.lua"] = { + loaded = true, + path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua", + url = "https://github.com/norcalli/nvim-colorizer.lua" + }, + ["nvim-gps"] = { + loaded = true, + path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-gps", + url = "https://github.com/SmiteshP/nvim-gps" + }, ["nvim-lsp-installer"] = { loaded = true, path = "/home/relms/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer", @@ -289,6 +299,11 @@ _G.packer_plugins = { path = "/home/relms/.local/share/nvim/site/pack/packer/start/vim-better-whitespace", url = "https://github.com/ntpeters/vim-better-whitespace" }, + ["vim-illuminate"] = { + loaded = true, + path = "/home/relms/.local/share/nvim/site/pack/packer/start/vim-illuminate", + url = "https://github.com/RRethy/vim-illuminate" + }, ["which-key.nvim"] = { loaded = true, path = "/home/relms/.local/share/nvim/site/pack/packer/start/which-key.nvim", @@ -302,5 +317,6 @@ if should_profile then save_profiles() end end) if not no_errors then + error_msg = error_msg:gsub('"', '\\"') vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') end