summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
Diffstat (limited to '.config')
-rw-r--r--.config/nvim/lua/autocmds.lua19
-rw-r--r--.config/nvim/lua/custom/completion.lua44
-rw-r--r--.config/nvim/lua/custom/lsp.lua24
-rw-r--r--.config/nvim/lua/keymaps.lua26
-rw-r--r--.config/nvim/lua/options.lua16
5 files changed, 58 insertions, 71 deletions
diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/autocmds.lua
index 82f1107..5272029 100644
--- a/.config/nvim/lua/autocmds.lua
+++ b/.config/nvim/lua/autocmds.lua
@@ -6,12 +6,13 @@ vim.api.nvim_create_autocmd('TextYankPost', {
end,
})
-vim.api.nvim_create_autocmd('FileType', {
- group = vim.api.nvim_create_augroup('disable-auto-comment', { clear = true }),
- pattern = '*',
- callback = function()
- -- c - autowrap using textwidth | r - enter in insert mode | o - o/O in normal mode
- -- vim.opt.formatoptions:remove({ 'c', 'r', 'o' })
- vim.cmd('set formatoptions-=co')
- end,
-})
+-- vim.api.nvim_create_autocmd('FileType', {
+-- group = vim.api.nvim_create_augroup('disable-auto-comment', { clear = true }),
+-- pattern = '*',
+-- callback = function()
+-- -- c - autowrap using textwidth | r - enter in insert mode | o - o/O in normal mode
+-- -- vim.opt.formatoptions:remove({ 'c', 'r', 'o' })
+-- vim.opt.formatoptions:remove('o')
+-- -- vim.cmd('set formatoptions-=o')
+-- end,
+-- })
diff --git a/.config/nvim/lua/custom/completion.lua b/.config/nvim/lua/custom/completion.lua
index 50df64b..80c9531 100644
--- a/.config/nvim/lua/custom/completion.lua
+++ b/.config/nvim/lua/custom/completion.lua
@@ -7,7 +7,7 @@ cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm
-- Helper functions
local function tab(is_forward)
- cmp.mapping(function(fallback)
+ return cmp.mapping(function(fallback)
local jump_amount = is_forward and 1 or -1
if cmp.visible() then
local behaviour = cmp.SelectBehavior.Select
@@ -21,8 +21,6 @@ local function tab(is_forward)
end, { 'i', 's' })
end
-local function enter() end
-
local function is_enabled()
local context = require('cmp.config.context')
@@ -43,6 +41,7 @@ cmp.setup({
{ name = 'lazydev', group_index = 0 }, -- for lazydev.nvim
{ name = 'path' }, -- for filesystem
}),
+
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
@@ -54,46 +53,19 @@ cmp.setup({
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
- -- TODO: Make good keybindings
['<Tab>'] = tab(true),
['<S-Tab>'] = tab(false),
- ['<CR>'] = cmp.mapping(function(fallback)
- if cmp.visible() then
- if luasnip.expandable() then
- luasnip.expand()
- else
- cmp.confirm({ select = true })
- end
- else
- fallback()
- end
- end),
-
+ ['<C-Space>'] = cmp.mapping.complete(), -- invoke completion
+ ['<CR>'] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }),
+ ['<C-u>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-d>'] = cmp.mapping.scroll_docs(4),
+ ['<C-m>'] = cmp.mapping.abort(),
-- NOTE: Select makes it so it doesn't put the text in the buffer (like Insert or defualt does)
-- Ex: typing "p" and then select "private" will not write "private" in your buffer, but keep it "p"
-- Only after accepting the suggestion then it'll become "private"
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
-
- ['<CR>'] = cmp.mapping(
- cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }),
- { 'i', 'c' }
- ),
-
- ['<C-Space>'] = cmp.mapping.complete(), -- invoke completion
- ['<C-u>'] = cmp.mapping.scroll_docs(-4),
- ['<C-d>'] = cmp.mapping.scroll_docs(4),
-
- -- ['<C-k>'] = cmp.mapping.abort(),
- -- ['<CR>'] = cmp.mapping.confirm({ select = true }),
- -- ['<C-y>'] = cmp.mapping(
- -- cmp.mapping.confirm({
- -- behavior = cmp.ConfirmBehavior.Insert,
- -- select = true,
- -- }),
- -- { 'i', 'c' }
- -- ),
}),
})
-print('Sourced lsp.lua')
+print('Sourced completion.lua')
diff --git a/.config/nvim/lua/custom/lsp.lua b/.config/nvim/lua/custom/lsp.lua
index 1238001..d534e22 100644
--- a/.config/nvim/lua/custom/lsp.lua
+++ b/.config/nvim/lua/custom/lsp.lua
@@ -1,18 +1,18 @@
-- NOTE: A list of language servers (and potentially their config)
-- Accepts either true to enable, false to disable or a table with settings
local servers = {
- lua_ls = true, -- lua
- clangd = true, -- C/C++
- gradle_ls = true, -- java package manager
- jdtls = true, -- java eclipse lsp
+ lua_ls = true, -- lua
+ clangd = true, -- C/C++
+ gradle_ls = true, -- java package manager
+ jdtls = true, -- java eclipse lsp
kotlin_language_server = true, -- kotlin
- pyright = true, -- python
- rust_analyzer = true, -- rust
- bashls = true, -- bash
- taplo = true, -- toml
- lemminx = true, -- xml
- yamlls = true, -- yaml
- jsonls = true, -- json
+ pyright = true, -- python
+ rust_analyzer = true, -- rust
+ bashls = true, -- bash
+ taplo = true, -- toml
+ lemminx = true, -- xml
+ yamlls = true, -- yaml
+ jsonls = true, -- json
}
-- NOTE: Not language servers but still make sure mason installs them
@@ -97,3 +97,5 @@ vim.api.nvim_create_autocmd('LspAttach', {
--
-- require('lsp_lines').setup()
-- vim.diagnostic.config({ virtual_text = false })
+
+print('Sourced lsp.lua')
diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua
index 6772f0f..a48679e 100644
--- a/.config/nvim/lua/keymaps.lua
+++ b/.config/nvim/lua/keymaps.lua
@@ -1,18 +1,26 @@
local set = vim.keymap.set
local silent = { silent = true }
+---@param mode string|table
+---@param keymap string
+local function unbind(mode, keymap)
+ set(mode, keymap, function() end)
+end
-- Misc
set({ 'n', 'i' }, '<C-a>', '<Esc>ggVG', { desc = 'Visually Highlight [A]ll' })
-set('n', '<Esc>', ':nohlsearch<CR>', silent)
-set({ 'i', 'c' }, '<C-v>', '<C-r>+')
+set('n', '<Esc>', '<cmd>nohlsearch<CR>', silent)
+set({ 'i', 'c' }, '<C-v>', function()
+ vim.fn.getreg('+')
+end)
set('n', '<leader>z', function()
vim.cmd('Neotree close')
vim.cmd('Trouble todo close')
vim.cmd('UndotreeHide')
end, { desc = '[Z]en Mode', silent = true })
+unbind({ 'i', 'n', 'v' }, '<C-r>')
-set('n', 'U', ':redo<cr>')
-set('i', '<C-z>', ':undo<cr>')
+set('n', 'U', '<cmd>redo<cr>')
+set('i', '<C-z>', '<cmd>undo<cr>')
-- Window Navigation
set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
@@ -22,10 +30,10 @@ set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
-- Window resizing
local resize = 2
-set({ 'n', 't' }, '<C-Left>', string.format(':vertical resize -%d<CR>', resize), { desc = 'Resize Left' })
-set({ 'n', 't' }, '<C-Up>', string.format(':resize -%d<CR>', resize), { desc = 'Resize Up' })
-set({ 'n', 't' }, '<C-Down>', string.format(':resize +%d<CR>', resize), { desc = 'Resize Down' })
-set({ 'n', 't' }, '<C-Right>', string.format(':vertical resize +%d<CR>', resize), { desc = 'Resize Right' })
+set({ 'n', 't' }, '<C-Left>', string.format('<cmd>vertical resize -%d<CR>', resize), { desc = 'Resize Left' })
+set({ 'n', 't' }, '<C-Up>', string.format('<cmd>resize -%d<CR>', resize), { desc = 'Resize Up' })
+set({ 'n', 't' }, '<C-Down>', string.format('<cmd>resize +%d<CR>', resize), { desc = 'Resize Down' })
+set({ 'n', 't' }, '<C-Right>', string.format('<cmd>vertical resize +%d<CR>', resize), { desc = 'Resize Right' })
-- Keep selection after < and > in visual mode
set('v', '<', '<gv')
@@ -34,3 +42,5 @@ set('v', '>', '>gv')
-- Execute lua file or line
set('n', '<leader>x', '<cmd>.lua<CR>', { desc = 'Execute the current line' })
set('n', '<leader><leader>x', '<cmd>source %<CR>', { desc = 'Execute the current file' })
+
+print('Sourced keymaps.lua')
diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua
index 85153de..0ff65b9 100644
--- a/.config/nvim/lua/options.lua
+++ b/.config/nvim/lua/options.lua
@@ -3,15 +3,15 @@ vim.g.maplocalleader = ' '
-- System
vim.g.have_nerd_font = true
-vim.opt.mouse = 'a' -- enable mouse
+vim.opt.mouse = 'a' -- enable mouse
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
vim.opt.undofile = true -- Persist undo history by saving it to a file
-- Tab
vim.opt.expandtab = true -- convert tabs to spaces
-vim.opt.tabstop = 4 -- number of visual spaces per TAB
-vim.opt.softtabstop = 4 -- number of idfk tab when editing
-vim.opt.shiftwidth = 4 -- number of spaces to insert on tab
+vim.opt.tabstop = 4 -- number of visual spaces per TAB
+vim.opt.softtabstop = 4 -- number of idfk tab when editing
+vim.opt.shiftwidth = 4 -- number of spaces to insert on tab
-- UI
vim.opt.signcolumn = 'auto:9'
@@ -35,9 +35,9 @@ vim.opt.wrap = false
vim.opt.scrolloff = 8
vim.opt.undofile = true
vim.opt.termguicolors = true
-vim.opt.laststatus = 3 -- views can only be fully collapsed with the global statusline
-vim.opt.splitkeep = 'screen' -- for edgy.nvim
-vim.opt.inccommand = 'split' -- shows preview for commands like :%s/from/to
+vim.opt.laststatus = 3 -- views can only be fully collapsed with the global statusline
+vim.opt.splitkeep = 'screen' -- for edgy.nvim
+vim.opt.inccommand = 'split' -- shows preview for commands like :%s/from/to
vim.opt.formatoptions:remove('o') -- don't have `o` add a comment
-- Disable warnings for missing language providers
@@ -45,3 +45,5 @@ vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_ruby_provider = 0
vim.g.loaded_python3_provider = 0
+
+print('Sourced options.lua')