dotfiles/config/nvim/init.lua

136 lines
6.6 KiB
Lua
Raw Normal View History

vim.opt.mouse = 'a' -- Enables mouse support in all modes
vim.opt.nu = true -- Enables line numbers
vim.opt.relativenumber = true -- Displays relative line numbers in the buffer
vim.opt.tabstop = 4 -- Sets the number of spaces that a tab character represents
vim.opt.softtabstop = 4 -- Sets the number of spaces per tab in the editor's buffer
vim.opt.shiftwidth = 4 -- Sets the width for autoindents
vim.opt.expandtab = true -- Converts tabs to spaces
vim.opt.smartindent = true -- Enables intelligent autoindenting for new lines
vim.opt.wrap = false -- Disables text wrapping
vim.opt.swapfile = false -- Disables swap file creation
vim.opt.backup = false -- Disables making a backup before overwriting a file
vim.opt.ignorecase = true -- Makes searches case insensitive
vim.opt.smartcase = true -- Makes searches case sensitive if there's a capital letter
vim.opt.hlsearch = true -- Highlights all matches of the search pattern
vim.opt.incsearch = true -- Starts searching before typing is finished
vim.opt.termguicolors = true -- Enables true color support
vim.opt.scrolloff = 20 -- Keeps 8 lines visible above/below the cursor
vim.opt.signcolumn = "yes" -- Always show the sign column
vim.opt.isfname:append("@-@") -- Allows '@' in filenames
vim.opt.clipboard = "unnamedplus" -- Uses the system clipboard for all yank, delete, change and put operations
vim.opt.undofile = true -- Enables persistent undo
vim.opt.updatetime = 50 -- Sets the time after which the swap file is written (in milliseconds)
vim.o.breakindent = true -- Makes wrapped lines visually indented
vim.o.termguicolors = true -- Enables true color support (duplicated setting)
vim.o.splitright = true -- Set horizontal splits to the right as default
vim.o.splitbelow = true -- Set vertical splits to the bottom as default
vim.o.completeopt = 'menuone,noselect' -- Configures how the completion menu works
vim.o.winborder = 'rounded' -- LSP hover borders
2026-02-12 07:26:59 +00:00
vim.opt.showmode = false
vim.opt.laststatus = 0
---------------------------------------------------------------------------------
-- [[ PLUGINS ]]
---------------------------------------------------------------------------------
vim.pack.add({
{ src = "https://github.com/rebelot/kanagawa.nvim" },
{ src = "https://github.com/neovim/nvim-lspconfig" },
{ src = "https://github.com/nvim-mini/mini.nvim" },
{ src = "https://github.com/stevearc/oil.nvim" },
{ src = "https://github.com/akinsho/toggleterm.nvim" },
{ src = "https://github.com/folke/trouble.nvim" },
2026-02-17 06:03:38 +00:00
{ src = "https://github.com/saghen/blink.cmp" },
2026-02-09 18:50:56 +00:00
{ src = "https://github.com/tribela/transparent.nvim" },
2026-02-12 07:26:59 +00:00
{ src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "master" },
2026-02-17 06:03:38 +00:00
{ src = "https://github.com/Teatek/gdscript-extended-lsp.nvim" },
})
2026-02-17 06:03:38 +00:00
require('winbar').setup()
require("trouble").setup()
require("mini.pick").setup()
require("mini.pairs").setup()
require("mini.surround").setup()
2026-02-17 06:03:38 +00:00
require('gdscript-extended-lsp').setup()
require("oil").setup({ view_options = { show_hidden = true, } })
require("toggleterm").setup({ open_mapping = [[<c-\>]], direction = "float" })
2026-02-17 06:03:38 +00:00
require('nvim-treesitter.configs').setup({ highlight = { enable = true, } })
require('blink.cmp').setup({
keymap = {
preset = 'none',
['<Tab>'] = { 'show', 'select_next', 'snippet_forward', 'fallback' },
['<S-Tab>'] = { 'select_prev', 'snippet_backward', 'fallback' },
['<CR>'] = { 'accept', 'fallback' },
},
completion = { documentation = { auto_show = false } },
sources = { default = { 'path', 'buffer', 'lsp' }, },
fuzzy = { implementation = "lua" }
})
vim.cmd.colorscheme("kanagawa")
2026-02-09 18:50:56 +00:00
---------------------------------------------------------------------------------
-- [[ KEYMAPS ]]
---------------------------------------------------------------------------------
vim.g.mapleader = " "
vim.keymap.set('n', '<Esc>', '<Cmd>noh<CR><Esc>', { silent = true })
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
vim.keymap.set('n', 'cr', '<cmd>lua vim.lsp.buf.rename()<cr>')
vim.keymap.set('n', 'ca', '<cmd>lua vim.lsp.buf.code_action()<cr>')
vim.keymap.set("v", "<S-Tab>", "<gv")
vim.keymap.set("v", "<Tab>", ">gv")
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "<leader>p", "<cmd>b#<CR>")
vim.keymap.set("n", "<leader>x", "<cmd>bd<CR>")
vim.keymap.set("n", "<leader>f", ":Pick files<CR>")
vim.keymap.set("n", "<leader>h", ":Pick help<CR>")
vim.keymap.set("n", "<leader>s", ":Pick grep_live<CR>")
vim.keymap.set("n", "<leader>b", ":Pick buffers<CR>")
vim.keymap.set("n", "<leader>q", ":Trouble diagnostics toggle<CR>")
vim.keymap.set("n", "<leader>e", ":Oil<CR>")
--------------------------------------------------------------------------------
-- [[ LSP ]]
---------------------------------------------------------------------------------
2026-02-09 18:50:56 +00:00
local servers = { "gopls", "gdscript" }
for _, server in ipairs(servers) do
vim.lsp.enable(server)
end
2026-02-09 18:50:56 +00:00
--------------------------------------------------------------------------------
-- [[ AUTOCMDS ]]
---------------------------------------------------------------------------------
-- Highlight on Yank
vim.api.nvim_create_autocmd('TextYankPost', {
group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
pattern = '*',
})
2026-02-12 07:26:59 +00:00
--------------------------------------------------------------------------------
-- [[ Godot ]]
---------------------------------------------------------------------------------
-- paths to check for project.godot file
local paths_to_check = {'/', '/../'}
local is_godot_project = false
local godot_project_path = ''
local cwd = vim.fn.getcwd()
-- iterate over paths and check
for key, value in pairs(paths_to_check) do
if vim.uv.fs_stat(cwd .. value .. 'project.godot') then
is_godot_project = true
godot_project_path = cwd .. value
break
end
end
-- check if server is already running in godot project path
local is_server_running = vim.uv.fs_stat(godot_project_path .. '/server.pipe')
if is_godot_project and not is_server_running then
vim.fn.serverstart(godot_project_path .. '/server.pipe')
end