Compare commits

..

10 commits

16 changed files with 207 additions and 38 deletions

View file

@ -1,2 +1,41 @@
# nvim
# Neovim
Neovim Configuration
![Screenshot]
This repository contains my Neovim configuration.
This Neovim configuration stay close to my [NixOS config] to keep up the dependencies used.
## Features (Configured for)
### Basic
- Syntax Highlighting via [Treesitter]
- Autocompletion and Git integration in the number column.
![Auto-Completion]
- LSP Integration
![Hover Window]
### Golang
- Auto detect implementation by [Gomplements] plugin.
![Gomplements-Pic]
- Generate stub implementation by searching the definition.
![Impl-Gif]
[NixOS config]: https://git.tigor.web.id/tigor/NixOS
[Treesitter]: https://github.com/nvim-treesitter/nvim-treesitter
[Hover Window]: https://public.tigor.web.id/git/images/neovim/hover.png
[Screenshot]: https://public.tigor.web.id/git/images/neovim/screenshot.png
[Auto-Completion]: https://public.tigor.web.id/git/images/neovim/autocomplete.png
[Gomplements]: https://github.com/maxandron/goplements.nvim
[Gomplements-Pic]: https://public.tigor.web.id/git/images/neovim/gomplements.png
[Impl-Gif]: https://public.tigor.web.id/git/images/neovim/impl.gif

View file

@ -48,6 +48,7 @@
"mini.icons": { "branch": "main", "commit": "fe63fe080e76d80713557e5f0c65bc15b14b152d" },
"mini.nvim": { "branch": "main", "commit": "7c00ea1a6b35332746e1a2fa768e26c5fa9c3589" },
"mini.pairs": { "branch": "main", "commit": "927d19cbdd0e752ab1c7eed87072e71d2cd6ff51" },
"mini.surround": { "branch": "main", "commit": "d8913ed23be0a1a4585ae34414821cc343a46174" },
"neo-tree.nvim": { "branch": "main", "commit": "206241e451c12f78969ff5ae53af45616ffc9b72" },
"neotest": { "branch": "master", "commit": "32ff2ac21135a372a42b38ae131e531e64833bd3" },
"neotest-golang": { "branch": "main", "commit": "cfaf82eeb198651dffabc6cf17b019a117147957" },
@ -66,11 +67,13 @@
"nvim-lint": { "branch": "master", "commit": "ad0fe35e80f5cd31a0f19176d7b30e5c3011119d" },
"nvim-lspconfig": { "branch": "master", "commit": "ff97d376b1d22b2eaf9274605531babf0cd0cf21" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
"nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" },
"nvim-treesitter": { "branch": "master", "commit": "e5a05ba5e298cc1e1dad8eb8095b8d4d89a7f793" },
"nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ca93cb2c34b67ab22d01976fc90bc95627a3317f" },
"nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" },
"one-small-step-for-vimkind": { "branch": "main", "commit": "0f0d5bc67786c36edc2cb6fb5faa5c09dd1a6e10" },
"peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" },
"persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" },
@ -91,6 +94,7 @@
"transparent.nvim": { "branch": "main", "commit": "2c78d94448b534c35ca1d88a3bae90b1cd1a3d4d" },
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
"ts-comments.nvim": { "branch": "main", "commit": "98d7d4dec0af1312d38e288f800bbf6ff562b6ab" },
"tssorter.nvim": { "branch": "main", "commit": "74fa4102cb3272dcc8fd5696fd3240358f19c090" },
"vim-caddyfile": { "branch": "master", "commit": "24fe0720551883e407cb70ae1d7c03f162d1d5a0" },
"vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" },
"vim-http": { "branch": "master", "commit": "7eb78e9753c10ca696d80a2668831bdd2aa08a92" },

View file

@ -3,7 +3,6 @@
"lazyvim.plugins.extras.editor.harpoon2",
"lazyvim.plugins.extras.lang.nix",
"lazyvim.plugins.extras.lang.rust",
"lazyvim.plugins.extras.lang.svelte",
"lazyvim.plugins.extras.lang.toml"
],
"news": {

View file

@ -6,9 +6,10 @@ require "config.neovide"
vim.keymap.set("t", "<c-d>", "<C-\\><C-n>", { silent = true, desc = "Exit Terminal Mode" })
vim.keymap.set(
"n",
"<leader>z",
"<cmd>silent !wezterm start --class lazygit --cwd . -- lazygit<cr>",
{ desc = "Open Lazygit" }
)
if vim.fn.executable "lazygit" == 1 then
require "config.lazygit"
end
if vim.env.HYPRLAND_INSTANCE_SIGNATURE ~= nil and vim.fn.executable "footclient" == 1 then
require "config.terminal"
end

View file

@ -16,6 +16,7 @@ require("lazy").setup {
{ import = "lazyvim.plugins.extras.coding.copilot" },
{ import = "lazyvim.plugins.extras.coding.yanky" },
{ import = "lazyvim.plugins.extras.coding.luasnip" },
{ import = "lazyvim.plugins.extras.coding.mini-surround" },
{ import = "lazyvim.plugins.extras.formatting.prettier" },
{ import = "lazyvim.plugins.extras.dap.core" },

31
lua/config/lazygit.lua Normal file
View file

@ -0,0 +1,31 @@
if vim.env.ZELLIJ ~= nil and not vim.g.neovide then
-- currently running inside zellij session and not inside neovide
vim.keymap.set("n", "<leader>z", function()
local cwd = vim.fn.expand "%:p:h"
vim.system {
"zellij",
"run",
"--close-on-exit",
"--cwd",
cwd,
"--in-place",
"--",
"lazygit",
}
end, { desc = "Open Lazygit (Zellij)" })
elseif vim.env.HYPRLAND_INSTANCE_SIGNATURE ~= nil and vim.fn.executable "foot" == 1 then
vim.keymap.set("n", "<leader>z", function()
vim.system {
"hyprctl",
"dispatch",
"exec",
"--",
"foot",
"--app-id=lazygit",
"--title=lazygit",
"--working-directory=" .. vim.fn.getcwd(),
"--",
"lazygit",
}
end, { desc = "Open Lazygit (Foot)" })
end

44
lua/config/terminal.lua Normal file
View file

@ -0,0 +1,44 @@
local session_id = math.random(1, 100000)
local app_id = ([[neovim-terminal-%d]]):format(session_id)
local class = ([[class:%s]]):format(app_id)
vim.keymap.set("n", "<F5>", function()
vim.system({ "hyprctl", "clients", "-j" }, { text = true }, function(output)
for _, client in ipairs(vim.json.decode(output.stdout)) do
if client.class == app_id then
-- focus instead of open new
vim.system { "hyprctl", "dispatch", "focuswindow", class }
return
end
end
vim.schedule(function()
vim.system({
"hyprctl",
"dispatch",
"exec",
"--",
"footclient",
"--working-directory",
vim.fn.getcwd(),
"--app-id",
app_id,
"--title=neovim-terminal",
}, {}, function()
vim.defer_fn(function()
vim.system {
"hyprctl",
"dispatch",
"resizewindowpixel",
([[exact 80%% 100%%,%s]]):format(class),
}
end, 50)
end)
vim.api.nvim_create_autocmd("VimLeave", {
pattern = "*",
callback = function()
vim.system { "hyprctl", "dispatch", "closewindow", class }
end,
})
end)
end)
end, { desc = "Open New terminal" })

View file

@ -40,8 +40,8 @@ return {
"SignColumn",
-- "CursorLine",
-- "CursorLineNr",
"StatusLine",
"StatusLineNC",
-- "StatusLine",
-- "StatusLineNC",
"EndOfBuffer",
},
}

View file

@ -16,6 +16,9 @@ return {
opts = function(_, opts)
local cmp = require "cmp"
table.insert(opts.sources, 3, { name = "async_path" })
opts.window = {
completion = cmp.config.window.bordered(),
}
if vim.fn.exepath "rg" ~= "" then
table.insert(opts.sources, 4, { name = "rg" })

View file

@ -9,7 +9,7 @@ return {
vim.env.GIT_EDITOR = [[nvr -cc split --remote-wait +'set bufhidden=wipe']]
end
end,
enabled = false,
enabled = (not vim.fn.executable "zellij" == 1) and (not vim.fn.executable "footclient" == 1),
keys = {
{ "<leader>z", "<cmd>LazyGit<cr>", desc = "Symbols Outline" },
},

View file

@ -7,6 +7,8 @@ return {
"gopls", -- gopls likes to be double attached if enabled here.
},
preferred_servers = {
gitcommit = {},
sql = {},
nix = {
"nil_ls",
},
@ -14,6 +16,7 @@ return {
"buf-language-server",
},
sh = {},
markdown = {},
},
},
-- enabled = false,

View file

@ -1,8 +1,37 @@
return {
{
"MeanderingProgrammer/markdown.nvim",
name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim
dependencies = { "nvim-treesitter/nvim-treesitter" },
config = function()
require("render-markdown").setup {}
end,
},
{
"toppair/peek.nvim",
ft = { "markdown" },
cmd = { "Peek" },
build = "deno task --quiet build:fast",
opts = function()
vim.api.nvim_create_autocmd("FileType", {
desc = "Create peek command on markdown ft",
pattern = "markdown",
callback = function(ev)
vim.api.nvim_buf_create_user_command(ev.buf, "Peek", function(ctx)
local peek = require "peek"
if peek.is_open() then
if ctx.bang then
peek.close()
end
return
end
peek.open()
end, { bang = true })
end,
})
return {
app = { "chromium", "--new-window" },
}
end,
},
}

9
lua/plugins/noice.lua Normal file
View file

@ -0,0 +1,9 @@
return {
"folke/noice.nvim",
opts = {
presets = {
lsp_doc_border = true,
inc_rename = true,
},
},
}

16
lua/plugins/svelte.lua Normal file
View file

@ -0,0 +1,16 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "svelte" } },
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
svelte = {
cmd = { "svelteserver", "--stdio" },
},
},
},
},
}

View file

@ -1,21 +0,0 @@
return {
"akinsho/toggleterm.nvim",
keys = {
{ "<F5>", "Open Toggleterm" },
},
cmd = { "ToggleTerm" },
version = "*",
opts = {
size = function(term)
if term.direction == "horizontal" then
if vim.o.lines < 60 then
return 12
end
return 20
elseif term.direction == "vertical" then
return vim.o.columns * 0.3
end
end,
open_mapping = [[<F5>]],
},
}

11
lua/plugins/ts_sort.lua Normal file
View file

@ -0,0 +1,11 @@
return {
"mtrajano/tssorter.nvim",
cmd = { "TSSort", "Sort" },
opts = function()
vim.api.nvim_create_user_command("Sort", "TSSort", {
desc = "Alias for TSSort. Sorts the treesitter nodes (keys, strings, list, etc) under the cursor while keeping the structure of the node.",
})
return {}
end, -- latest stable version, use `main` to keep up with the latest changes
version = false,
}