Skip to content

Commit

Permalink
feat(nvim): update to 0.10 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
schardev committed May 23, 2024
1 parent f0384c2 commit 17bcdf5
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 128 deletions.
1 change: 0 additions & 1 deletion config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ local lazy_config = {
"tarPlugin",
"tutor",
"tutor_mode_plugin",
"vimball",
"zip",
"zipPlugin",
},
Expand Down
67 changes: 33 additions & 34 deletions config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
{
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "b152822e1a4bafb6bdf11a16cc26525cbd95ee00" },
"LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" },
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
"bufferline.nvim": { "branch": "main", "commit": "73540cb95f8d95aa1af3ed57713c6720c78af915" },
"catppuccin": { "branch": "main", "commit": "a1439ad7c584efb3d0ce14ccb835967f030450fe" },
"bufferline.nvim": { "branch": "main", "commit": "73edc1f2732678e7a681e3d3be49782610914f6b" },
"catppuccin": { "branch": "main", "commit": "d97387aea8264f484bb5d5e74f2182a06c83e0d8" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-calc": { "branch": "main", "commit": "ce91d14d2e7a8b3f6ad86d85e34d41c1ae6268d9" },
"cmp-calc": { "branch": "main", "commit": "5947b412da67306c5b68698a02a846760059be2e" },
"cmp-git": { "branch": "main", "commit": "b9603f18496bc3ca07e6bd474607081af709e750" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp-spell": { "branch": "master", "commit": "32a0867efa59b43edbb2db67b0871cfad90c9b66" },
"cmp-spell": { "branch": "master", "commit": "694a4e50809d6d645c1ea29015dad0c293f019d6" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "12b3995537f52ba2810a9857e8ca256881febbda" },
"fidget.nvim": { "branch": "main", "commit": "1ba38e4cbb24683973e00c2e36f53ae64da38ef5" },
"gitsigns.nvim": { "branch": "main", "commit": "790355f00af1fc2c330ea1b2b7f68d65f19b57c9" },
"indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" },
"lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" },
"leap.nvim": { "branch": "main", "commit": "626be4c4ec040aeaf6466c9aae17ee0ab09f1a5b" },
"conform.nvim": { "branch": "master", "commit": "f3b930db4964d60e255c8f9e37b7f2218dfc08cb" },
"fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" },
"gitsigns.nvim": { "branch": "main", "commit": "cdfcd9d39d23c46ae9a040de2c6a8b8bf868746e" },
"indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" },
"lazy.nvim": { "branch": "main", "commit": "8f19915175395680808de529e4220da8dafc0759" },
"leap.nvim": { "branch": "main", "commit": "8f4d3ab9fe5c906c5745150191831c5ee0a427a0" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "273fdde8ac5e51f3a223ba70980e52bbc09d9f6f" },
"mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "a4caa0d083aab56f6cd5acf2d42331b74614a585" },
"mason.nvim": { "branch": "main", "commit": "49ff59aded1047a773670651cfa40e76e63c6377" },
"neodev.nvim": { "branch": "main", "commit": "ce9a2e8eaba5649b553529c5498acb43a6c317cd" },
"neogen": { "branch": "main", "commit": "0daffcec249bf42275e322361fe55b89a05ff278" },
"nvim-autopairs": { "branch": "master", "commit": "4f41e5940bc0443fdbe5f995e2a596847215cd2a" },
"nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" },
"neogen": { "branch": "main", "commit": "6de0add4805165317ab7d3d36b5cef48b1b865f3" },
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
"nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" },
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
"nvim-lint": { "branch": "master", "commit": "861a04313501563bb1b11f125ae9b7237a517b9b" },
"nvim-lspconfig": { "branch": "master", "commit": "aa5f4f4ee10b2688fb37fa46215672441d5cd5d9" },
"nvim-surround": { "branch": "main", "commit": "6d0dc3dbb557bcc6a024969da461df4ba803fc48" },
"nvim-tree.lua": { "branch": "master", "commit": "347e1eb35264677f66a79466bb5e3d111968e12c" },
"nvim-treesitter": { "branch": "master", "commit": "9a47a523e3b9e49d3fa14d5743b9860a66eca731" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "23b820146956b3b681c19e10d3a8bc0cbd9a1d4c" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "a6382f744f584bbf71d0a563af789af7190aabda" },
"nvim-vtsls": { "branch": "main", "commit": "2a63038478806349daec51cdfb146ac6ff4cc4b2" },
"nvim-web-devicons": { "branch": "master", "commit": "794bba734ec95eaff9bb82fbd112473be2087283" },
"persistence.nvim": { "branch": "main", "commit": "4982499c1636eac254b72923ab826ee7827b3084" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "7ef0766b5cd2f5cdf4fcb08886f0a2ebf65981fa" },
"schemastore.nvim": { "branch": "main", "commit": "3289a23407dbd7b78f49316f3227368ad63b71b6" },
"nvim-lint": { "branch": "master", "commit": "e19842a05aae484957ad20710444757bc0a61d63" },
"nvim-lspconfig": { "branch": "master", "commit": "2c1877081b237a643e52ebdebaf36c84a2695639" },
"nvim-surround": { "branch": "main", "commit": "79aaa42da1f698ed31bcbe7f83081f69dca7ba17" },
"nvim-tree.lua": { "branch": "master", "commit": "2bc725a3ebc23f0172fb0ab4d1134b81bcc13812" },
"nvim-treesitter": { "branch": "master", "commit": "298a9dd4f8a0d95b347a7ebd301849d8b0e3917e" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "3557e41418b4a6c5b85d5d64abe94c9c50fa9b14" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
"nvim-vtsls": { "branch": "main", "commit": "719fabc328c48fa03b1f3373205fcd1f60d21dc2" },
"nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" },
"persistence.nvim": { "branch": "main", "commit": "5fe077056c821aab41f87650bd6e1c48cd7dd047" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "5d0d30b201566ce1fe31415f41fe2a7bdf56f4a7" },
"schemastore.nvim": { "branch": "main", "commit": "9a5992a881583d886bfbb46631a09f736f0fae50" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
"telescope.nvim": { "branch": "master", "commit": "2d0d057791854decb2c9b6a0b52d43f3900dff40" },
"telescope.nvim": { "branch": "master", "commit": "5665d93988acfbb0747bdbf4f4cb583bcebc8930" },
"undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" },
"vim-fugitive": { "branch": "master", "commit": "dac8e5c2d85926df92672bf2afb4fc48656d96c7" },
"vim-fugitive": { "branch": "master", "commit": "4f59455d2388e113bd510e85b310d15b9228ca0d" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}
38 changes: 13 additions & 25 deletions config/nvim/lua/core/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ local mapper = utils.mapper_factory
local nnoremap = mapper("n")
local tnoremap = mapper("t")
local vnoremap = mapper("v")
local xnoremap = mapper("x")

-- No need to keep holding shift
nnoremap(";", ":", { silent = false })
Expand Down Expand Up @@ -63,6 +62,12 @@ end, { desc = "Toggle wrap" })
-- Don't put text in register on delete char
mapper({ "n", "v" })("x", '"_x')

-- Copy to system clipboard
mapper({ "x", "n" })("<Leader>y", [["+y]])

-- Replicate netrw functionality (gx/gf)
nnoremap("gx", utils.open)

-- Keep visual mode indenting
vnoremap("<", "<gv")
vnoremap(">", ">gv")
Expand All @@ -82,14 +87,11 @@ nnoremap("<Leader>se", utils.save_and_exec, {
nnoremap("]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic" })
nnoremap("[d", vim.diagnostic.goto_prev, { desc = "Go to prev diagnostic" })
nnoremap("<Leader>td", function()
if vim.b.show_diagnostics then
vim.notify("[LSP] Disabled diagnostics.")
vim.diagnostic.disable(0)
else
vim.notify("[LSP] Enabled diagnostics.")
vim.diagnostic.enable(0)
end
vim.b.show_diagnostics = not vim.b.show_diagnostics
local is_enabled = vim.diagnostic.is_enabled()
vim.diagnostic.enable(not is_enabled)
vim.notify(
"[LSP] " .. (is_enabled and "Disabled" or "Enabled") .. " diagnostics."
)
end, { desc = "Toggle diagnostics" })

-- Make <Esc> to actually escape from terminal mode
Expand All @@ -105,10 +107,10 @@ nnoremap("dd", function()
end, { expr = true })

-- Toggle highlights
nnoremap("<Leader>sh", ":set hlsearch!<CR>", {
nnoremap("<Leader>ts", ":set hlsearch!<CR>", {
desc = "Toggle search highlighting",
})
nnoremap("<Leader>th", function()
nnoremap("<Leader>tt", function()
if vim.w.whitespace_highlight == true then
vim.cmd("highlight clear Tabs")
vim.cmd("highlight clear ExtraWhitespace")
Expand All @@ -126,14 +128,6 @@ end, {
--- Few mappings I stole from @akinsho :)
---@see https://github.com/akinsho/dotfiles/blob/main/.config/nvim/

xnoremap("@", function()
-- TODO: https://github.com/neovim/neovim/issues/18340
-- vim.ui.input({ prompt = "Macro Register: " }, function(reg)
-- vim.cmd([['<,'>normal @q]])
-- end)
return ":normal @" .. vim.fn.getcharstr() .. "<CR>"
end, { silent = false, expr = true })

-- Quick find and replace
vnoremap(
"<Leader>rr",
Expand Down Expand Up @@ -193,9 +187,3 @@ nnoremap("cQ", [[:\<C-u>call v:lua.Setup_CR()<CR>#``qz]])
-- [[":\<C-u>call v:lua.Setup_CR()<CR>gv" . substitute(g:mc, '/', '?', 'g') . "``qz"]],
-- { expr = true }
-- )

-- Replicate netrw functionality (gx/gf)
nnoremap("gx", utils.open_link)

-- few greatest remaps ever (courtesy of @theprimeagen)
mapper({ "x", "n" })("<Leader>y", [["+y]])
10 changes: 0 additions & 10 deletions config/nvim/lua/core/options.lua
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
local set = vim.o
local opt = vim.opt
local cmd = vim.cmd
local CONFIG_DIR = require("core.env").NVIM_USER_CONFIG_DIR

-- stylua: ignore start
cmd('filetype plugin indent on ') -- Used for indentation based on file-type
cmd('syntax enable') -- Enable syntax highlighting
set.backup = false -- Disable backup
set.breakindent = true -- Preserve indentation while wrapping
set.cmdheight = 2 -- Set command panel height
set.colorcolumn = "80" -- Highlight 80th column
set.cursorline = true -- Highlight current line number
set.encoding = "utf-8" -- It's the default in nvim but vim sets it conditionally
opt.fillchars = {vert = '', eob = '~'} -- Set vertical and empty lines chars
set.foldlevel = 99 -- Fold after this level (hax to prevent folding by default)
set.hidden = true -- Allow buffers to be hidden
set.hlsearch = false -- Disable search highlighting
set.ignorecase = true -- Ignore case for pattern matching by default
set.incsearch = true -- Incrementally highlights search patterns
set.laststatus = 3 -- Enable global statusline
set.lazyredraw = true -- Don't redrawn while executing macros
set.mouse = "n" -- Enable mouse support in normal only
set.number = true -- Show line numbers
set.numberwidth = 2 -- Minimal number of columns to use for the line number
set.relativenumber = true -- Shows line number relative to the current line
set.scrolloff = 5 -- Scroll offset
set.shell = "bash" -- Set default shell to bash coz zsh isn't POSIX-compatible
set.spellfile = CONFIG_DIR .. '/nvim/spell/en.utf-8.add'
set.splitright = true -- Splits windows to the right by default
set.smartcase = true -- Override `ignorecase` where possible
Expand All @@ -48,7 +39,6 @@ opt.wildignore:append({ -- Ignore these directories/files while
set.wildignorecase = true -- Ignore case while completing file
set.wrap = false -- Do not wrap code by default
set.writebackup = false -- Disable backup
set.termguicolors = true -- Term supports gui colors
set.title = true -- Set window title appropriately
set.pumblend=15 -- Enable a subtle transparency effect on pop-up menu
set.signcolumn="yes:2" -- Reserve space for atleast two signs
Expand Down
41 changes: 18 additions & 23 deletions config/nvim/lua/core/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,37 @@ function M.navigate_pane_or_window(direction)
if current_winnr ~= vim.fn.winnr(direction) then
vim.cmd("wincmd " .. direction)
else
vim.fn.system(
string.format(
"wezterm cli activate-pane-direction %s",
wezterm_direction[direction]
)
)
end
end

--- Opens the given path with `xdg_open`
---@param path string
function M.xdg_open(path)
if path then
vim.fn.jobstart({ "xdg-open", path }, { detach = true })
vim.notify(string.format("Opening %s", path))
else
vim.notify("path is null", vim.log.levels.ERROR)
vim.system({
"wezterm",
"cli",
"activate-pane-direction",
wezterm_direction[direction],
})
end
end

--- Open the current file/word under cursor in vim if it exists else open it via xdg_open
function M.open_link()
function M.open()
local file = vim.fn.expand("<cfile>")
if vim.fn.isdirectory(file) > 0 then
return vim.cmd("edit " .. file)
if file:match("https?://") then
return vim.ui.open(file)
end

if file:match("https?://") then
return M.xdg_open(file)
if vim.fn.filereadable(vim.fn.expand(file)) > 0 then
return vim.cmd("edit " .. file)
end

-- consider anything that looks like string/string a github link
local plugin_url_regex = "[%a%d%-%.%_]*%/[%a%d%-%.%_]*"
local link = string.match(file, plugin_url_regex)
if link then
return M.xdg_open(string.format("https://www.github.com/%s", link))
return vim.ui.open(string.format("https://www.github.com/%s", link))
end

-- fallback to system open
local _, err = vim.ui.open(file)
if err then
vim.notify(err, vim.log.levels.ERROR)
end
end

Expand Down
17 changes: 6 additions & 11 deletions config/nvim/lua/plugins/lsp/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,22 @@ local diagnostics_prefix = function(diagnostic)
end

function M.setup()
for _, severity in pairs(diagnostics_signs) do
vim.fn.sign_define(severity.hl_group, {
text = severity.sign,
texthl = severity.hl_group,
numhl = severity.hl_group,
})
local signs = { text = {} }
for severity, config in pairs(diagnostics_signs) do
signs.text[severity] = config.sign
end

-- Global diagnostic config
vim.diagnostic.config({
virtual_text = function()
-- Disable virtual text on smaller screens
return vim.fn.winwidth(0) > 100
end,
signs = signs,
virtual_text = { prefix = diagnostics_prefix },
float = {
max_width = 85,
max_height = 30,
border = "rounded",
prefix = diagnostics_prefix,
scope = "line",
source = "always",
source = true,
},
underline = {
-- Do not underline text when severity is low (INFO or HINT).
Expand Down
27 changes: 13 additions & 14 deletions config/nvim/lua/plugins/lsp/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ local mapper = require("core.utils").mapper_factory
local nnoremap = mapper("n")

M.attach = function(args)
local bufnr = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client then
return
end

local bufnr = args.buf
local lsp_utils = require("plugins.lsp.utils")
vim.b[bufnr].show_diagnostics = true

mapper({ "n", "v" })(
"<LocalLeader>ca",
Expand All @@ -29,6 +32,11 @@ M.attach = function(args)

nnoremap("K", vim.lsp.buf.hover, { buffer = bufnr })
nnoremap("<C-k>", vim.lsp.buf.signature_help, { buffer = bufnr })
nnoremap(
"<LocalLeader>rn",
vim.lsp.buf.rename,
{ buffer = bufnr, desc = "Rename symbol under cursor" }
)

nnoremap(
"gD",
Expand All @@ -51,19 +59,10 @@ M.attach = function(args)
vim.lsp.buf.references,
{ buffer = bufnr, desc = "List all references" }
)

if client.server_capabilities.hoverProvider then
nnoremap(
"gt",
vim.lsp.buf.type_definition,
{ buffer = bufnr, desc = "Go to type definition" }
)
end

nnoremap(
"<LocalLeader>rn",
vim.lsp.buf.rename,
{ buffer = bufnr, desc = "Rename symbol under cursor" }
"gt",
vim.lsp.buf.type_definition,
{ buffer = bufnr, desc = "Go to type definition" }
)

if client.name == "tsserver" or client.name == "vtsls" then
Expand Down
11 changes: 1 addition & 10 deletions config/nvim/lua/plugins/nvim-treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ return {
command = "setlocal foldmethod=expr foldexpr=nvim_treesitter#foldexpr()",
})

---@diagnostic disable-next-line: missing-fields
require("nvim-treesitter.configs").setup({
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = enabled_parsers,
Expand Down Expand Up @@ -197,14 +198,4 @@ return {
})
end,
},

-- treesitter querying
-- adding it seperately here for lazy loading
{
"nvim-treesitter/playground",
cmd = {
"TSHighlightCapturesUnderCursor",
"TSPlaygroundToggle",
},
},
}

0 comments on commit 17bcdf5

Please sign in to comment.