summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/custom/config
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-04-24 11:36:39 +0300
committerKyren223 <Kyren223@proton.me>2025-04-24 11:36:39 +0300
commit6bef8f32b19778fdfe52f0eb39719425508dcc7b (patch)
treef293141ed7e8676b76bb06c07a0fa9472b10e2ac /.config/nvim/lua/custom/config
parentdbd9a6fdd0c44e26b200fb706aacd120a2e09c47 (diff)
Refactored nvim config to make it easier and less insanely nested
Diffstat (limited to '.config/nvim/lua/custom/config')
-rw-r--r--.config/nvim/lua/custom/config/cmp.lua143
-rw-r--r--.config/nvim/lua/custom/config/commands.lua121
-rw-r--r--.config/nvim/lua/custom/config/dap-keymaps.lua18
-rw-r--r--.config/nvim/lua/custom/config/keymaps.lua99
-rw-r--r--.config/nvim/lua/custom/config/language-servers.lua155
-rw-r--r--.config/nvim/lua/custom/config/lsp-keymaps.lua73
-rw-r--r--.config/nvim/lua/custom/config/lsp.lua73
-rw-r--r--.config/nvim/lua/custom/config/lualine.lua92
-rw-r--r--.config/nvim/lua/custom/config/options.lua61
-rw-r--r--.config/nvim/lua/custom/config/rustaceanvim.lua37
-rw-r--r--.config/nvim/lua/custom/config/telescope.lua41
11 files changed, 0 insertions, 913 deletions
diff --git a/.config/nvim/lua/custom/config/cmp.lua b/.config/nvim/lua/custom/config/cmp.lua
deleted file mode 100644
index e9f657c..0000000
--- a/.config/nvim/lua/custom/config/cmp.lua
+++ /dev/null
@@ -1,143 +0,0 @@
--- Load cmp_opts
-for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do
- loadfile(ft_path)()
-end
-
-local luasnip = require('luasnip')
-local lspkind = require('lspkind')
-local cmp = require('cmp')
-
--- Enable paretheses for function completions
-cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm_done())
-
--- Helper functions
-local function snippet_jump(jump_amount)
- return cmp.mapping(function(fallback)
- if luasnip.locally_jumpable(jump_amount) then
- luasnip.jump(jump_amount)
- else
- fallback()
- end
- end, { 'i', 's' })
-end
-
-local function is_enabled()
- local context = require('cmp.config.context')
-
- local is_in_comment = context.in_treesitter_capture('comment') or context.in_syntax_group('Comment')
- if is_in_comment then
- return false
- end
-
- return true
-end
-
-cmp.setup({
- enabled = is_enabled,
- preselect = cmp.PreselectMode.None,
- completion = { completeopt = 'menu,menuone,noinsert' },
- sources = cmp.config.sources({
- { name = 'luasnip' }, -- for snippets
- {
- name = 'nvim_lsp',
- option = {
- markdown_oxide = {
- keyword_pattern = [[\(\k\| \|\/\|#\)\+]],
- },
- },
- }, -- for lsp
- { name = 'lazydev', group_index = 0 }, -- for lazydev.nvim
- { name = 'path' }, -- for filesystem
- }, {}),
- snippet = {
- expand = function(args)
- luasnip.lsp_expand(args.body)
- end,
- },
- window = {
- documentation = cmp.config.window.bordered(),
- completion = {
- border = 'rounded',
- winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,Search:None',
- col_offset = -3,
- side_padding = 0,
- },
- },
- ---@diagnostic disable-next-line: missing-fields
- sorting = {
- comparators = {
- cmp.config.compare.offset,
- cmp.config.compare.exact,
- cmp.config.compare.recently_used,
- require('clangd_extensions.cmp_scores'),
- cmp.config.compare.kind,
- cmp.config.compare.sort_text,
- cmp.config.compare.length,
- cmp.config.compare.order,
- },
- },
- mapping = {
- ['<Tab>'] = snippet_jump(1),
- ['<S-Tab>'] = snippet_jump(-1),
- ['<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-c>'] = cmp.mapping.abort(),
- ['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
- ['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
- },
- ---@diagnostic disable-next-line: missing-fields
- formatting = {
- fields = { 'kind', 'abbr', 'menu' },
- format = function(entry, vim_item)
- local kind = lspkind.cmp_format({ mode = 'symbol_text', maxwidth = 50 })(entry, vim_item)
- local strings = vim.split(kind.kind, '%s', { trimempty = true })
- kind.kind = ' ' .. (strings[1] or '') .. ' ' -- left (icon)
- kind.menu = ' ' .. (strings[2] or '') .. '' -- right (text)
- return kind
- end,
- },
-})
-
--- -- Customization for Pmenu
--- vim.api.nvim_set_hl(0, 'PmenuSel', { bg = '#282C34', fg = 'NONE' })
--- vim.api.nvim_set_hl(0, 'Pmenu', { fg = '#C5CDD9', bg = '#22252A' })
---
-vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { fg = '#ff8294', bg = 'NONE', strikethrough = true })
--- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { fg = '#82AAFF', bg = 'NONE', bold = true })
--- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { fg = '#82AAFF', bg = 'NONE', bold = true })
--- vim.api.nvim_set_hl(0, 'CmpItemMenu', { fg = '#C792EA', bg = 'NONE', italic = true })
---
--- vim.api.nvim_set_hl(0, 'CmpItemKindField', { fg = '#EED8DA', bg = '#B5585F' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { fg = '#EED8DA', bg = '#B5585F' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindEvent', { fg = '#EED8DA', bg = '#B5585F' })
---
--- vim.api.nvim_set_hl(0, 'CmpItemKindText', { fg = '#C3E88D', bg = '#9FBD73' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindEnum', { fg = '#C3E88D', bg = '#9FBD73' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { fg = '#C3E88D', bg = '#9FBD73' })
---
--- vim.api.nvim_set_hl(0, 'CmpItemKindConstant', { fg = '#FFE082', bg = '#D4BB6C' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindConstructor', { fg = '#FFE082', bg = '#D4BB6C' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindReference', { fg = '#FFE082', bg = '#D4BB6C' })
---
--- vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { fg = '#EADFF0', bg = '#A377BF' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindStruct', { fg = '#EADFF0', bg = '#A377BF' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindClass', { fg = '#EADFF0', bg = '#A377BF' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindModule', { fg = '#EADFF0', bg = '#A377BF' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindOperator', { fg = '#EADFF0', bg = '#A377BF' })
---
--- vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { fg = '#C5CDD9', bg = '#7E8294' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindFile', { fg = '#C5CDD9', bg = '#7E8294' })
---
--- vim.api.nvim_set_hl(0, 'CmpItemKindUnit', { fg = '#F5EBD9', bg = '#D4A959' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindSnippet', { fg = '#F5EBD9', bg = '#D4A959' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindFolder', { fg = '#F5EBD9', bg = '#D4A959' })
---
--- vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { fg = '#DDE5F5', bg = '#6C8ED4' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindValue', { fg = '#DDE5F5', bg = '#6C8ED4' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindEnumMember', { fg = '#DDE5F5', bg = '#6C8ED4' })
---
--- vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { fg = '#D8EEEB', bg = '#58B5A8' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindColor', { fg = '#D8EEEB', bg = '#58B5A8' })
--- vim.api.nvim_set_hl(0, 'CmpItemKindTypeParameter', { fg = '#D8EEEB', bg = '#58B5A8' })
diff --git a/.config/nvim/lua/custom/config/commands.lua b/.config/nvim/lua/custom/config/commands.lua
deleted file mode 100644
index 7135eeb..0000000
--- a/.config/nvim/lua/custom/config/commands.lua
+++ /dev/null
@@ -1,121 +0,0 @@
-vim.api.nvim_create_autocmd('TextYankPost', {
- desc = 'Highlight when yanking text',
- group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }),
- callback = function()
- vim.highlight.on_yank()
- end,
-})
-
-vim.api.nvim_create_autocmd('BufEnter', {
- desc = 'Disable newlines on commented lines from continuing the comment',
- group = vim.api.nvim_create_augroup('disable-comments-continuation', { clear = true }),
- callback = function()
- -- vim.opt_local.formatoptions:remove('r') -- no comments on enter
- vim.opt_local.formatoptions:remove('o') -- no comments on `o` or `O`
- end,
-})
-
-vim.api.nvim_create_user_command('Format', function(args)
- local range = nil
- if args.count ~= -1 then
- local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
- range = {
- start = { args.line1, 0 },
- ['end'] = { args.line2, end_line:len() },
- }
- end
- require('conform').format({ async = true, lsp_format = 'fallback', range = range })
-end, { range = true })
-
-vim.api.nvim_create_user_command('FormatToggle', function(args)
- local is_global = not args.bang
- if is_global then
- vim.g.disable_autoformat = not vim.g.disable_autoformat
- if vim.g.disable_autoformat then
- Snacks.notify.info('Autoformat on save disabled globally', { title = 'test' })
- else
- Snacks.notify.info('Autoformat on save enabled globally')
- end
- else
- vim.b.disable_autoformat = not vim.b.disable_autoformat
- if vim.b.disable_autoformat then
- Snacks.notify.info('Autoformat on save disabled for this buffer')
- else
- Snacks.notify.info('Autoformat on save enabled for this buffer')
- end
- end
-end, {
- desc = 'Toggle autoformat on save',
- bang = true,
-})
-
--- NOTE: highlight %v, %s etc in go string literals
-vim.api.nvim_create_autocmd({ 'BufEnter', 'TextChanged', 'InsertLeave' }, {
- pattern = '*.go',
- callback = function()
- local query = vim.treesitter.query.parse('go', '(interpreted_string_literal) @string')
- local parser = vim.treesitter.get_parser(0, 'go')
- local tree = parser:parse()[1]
- local root = tree:root()
- local bufnr = vim.api.nvim_get_current_buf()
-
- for id, node in query:iter_captures(root, bufnr, 0, -1) do
- if query.captures[id] == 'string' then
- local start_row, start_col, end_row, end_col = node:range()
-
- -- Get the text of the string literal
- local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {})[1]
-
- -- Highlight only the parts matching `%[a-z]`
- for match_start, match_end in text:gmatch('()%%[a-z]()') do
- vim.api.nvim_buf_add_highlight(
- bufnr,
- -1,
- '@lsp.type.formatSpecifier.go', -- Higlight group
- start_row,
- start_col + match_start - 1,
- start_col + match_end - 1
- )
- end
- end
- end
- end,
-})
-
--- NOTE: show unused zig variables as "DiagnosticUnnecessary" instead of error
-local orig_underline_show = vim.diagnostic.handlers.underline.show
-local custom_ns = vim.api.nvim_create_namespace('custom_unused_ns')
-
-vim.diagnostic.handlers.underline.show = function(namespace, bufnr, diagnostics, opts)
- local normal_diags = {}
- local custom_diags = {}
- for _, diag in ipairs(diagnostics) do
- if diag.message:find('unused', 1, true) then
- table.insert(custom_diags, diag)
- else
- table.insert(normal_diags, diag)
- end
- end
- if #normal_diags > 0 and orig_underline_show ~= nil then
- orig_underline_show(namespace, bufnr, normal_diags, opts)
- end
- for _, diag in ipairs(custom_diags) do
- vim.highlight.range(
- bufnr,
- custom_ns,
- 'DiagnosticUnnecessary',
- { diag.lnum, diag.col },
- { diag.end_lnum, diag.end_col },
- { inclusive = false }
- )
- end
-end
-
-local orig_underline_hide = vim.diagnostic.handlers.underline.hide
-
-vim.diagnostic.handlers.underline.hide = function(namespace, bufnr)
- if orig_underline_hide ~= nil then
- orig_underline_hide(namespace, bufnr)
- end
- vim.api.nvim_buf_clear_namespace(bufnr, custom_ns, 0, -1)
-end
diff --git a/.config/nvim/lua/custom/config/dap-keymaps.lua b/.config/nvim/lua/custom/config/dap-keymaps.lua
deleted file mode 100644
index 8c3d540..0000000
--- a/.config/nvim/lua/custom/config/dap-keymaps.lua
+++ /dev/null
@@ -1,18 +0,0 @@
-local keymaps = {
- { 'n', '<leader>dr', '<cmd>DapContinue<cr>', { desc = '[D]ebug [R]esume (or start)' } },
- { 'n', '<leader>dR', '<cmd>DapRestartFrame<cr>', { desc = '[D]ebug [R]estart' } },
- { 'n', '<leader>dt', '<cmd>DapRestartFrame<cr>', { desc = '[D]ebug [R]estart' } },
- { 'n', '<leader>dp', '<cmd>DapToggleBreakpoint<cr>', { desc = '[D]ebug Break[p]oint' } },
- { 'n', '<leader>dh', '<cmd>lua require("dap.ui.widgets").hover()<cr>', { desc = '[D]ebug [H]over' } },
- { 'n', '<leader>si', '<cmd>DapStepInto<cr>', { desc = '[S]tep [I]nto' } },
- { 'n', '<leader>so', '<cmd>DapStepOver<cr>', { desc = '[S]tep [O]ver' } },
- { 'n', '<leader>sO', '<cmd>DapStepOut<cr>', { desc = '[S]tep [O]ut' } },
-}
-
-for _, keymap in ipairs(keymaps) do
- local mode = keymap[1]
- local lhs = keymap[2]
- local rhs = keymap[3]
- local opts = keymap[4] or {}
- vim.keymap.set(mode, lhs, rhs, opts)
-end
diff --git a/.config/nvim/lua/custom/config/keymaps.lua b/.config/nvim/lua/custom/config/keymaps.lua
deleted file mode 100644
index 36134dd..0000000
--- a/.config/nvim/lua/custom/config/keymaps.lua
+++ /dev/null
@@ -1,99 +0,0 @@
-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
-
-local function toggle_zen()
- vim.cmd('Neotree close')
- vim.cmd('Trouble todo close')
- vim.cmd('UndotreeHide')
-end
-
-local function yank_filepath_to_clipboard(os)
- return function()
- local filepath = vim.fn.expand('%:p')
- if os == 'linux' then
- local home_dir = vim.fn.expand('~')
- filepath = filepath:gsub(home_dir, '~')
- elseif os == 'windows' then
- local mnt = '/mnt/'
- if filepath:sub(1, #mnt) == mnt then
- filepath = filepath:sub(#mnt + 1, #mnt + 1) .. ':' .. filepath:sub(#mnt + 2)
- else
- filepath = '//wsl.localhost/openSUSE-Tumbleweed' .. filepath
- end
- filepath = filepath:gsub('/', '\\')
- end
- vim.fn.setreg('+', filepath)
- end
-end
-
-function RemoveClipboardCR()
- local clipboard = vim.fn.getreg('+'):gsub('\r', '')
- vim.fn.setreg('+', clipboard)
-end
-
-local function paste()
- RemoveClipboardCR()
- local value = vim.fn.getreg('+')
- if vim.fn.mode() == 'c' then
- -- value = vim.split(value, '\n')[1] -- only use first line (default with normal pasting)
- value = value:gsub('\n', ' ') -- replace newlines with spaces
- vim.api.nvim_feedkeys(value, 'c', false)
- else
- vim.api.nvim_put(vim.split(value, '\n'), 'c', false, true)
- end
-end
-
--- "Greatest Keymap ever" - ThePrimeagen
--- https://www.youtube.com/watch?v=qZO9A5F6BZs&list=PLm323Lc7iSW_wuxqmKx_xxNtJC_hJbQ7R&index=4
-set('x', '<leader>p', '<cmd>lua RemoveClipboardCR()<cr>"_dP')
-
-set({ 'n', 'x' }, 'p', '<cmd>lua RemoveClipboardCR()<cr>p', { noremap = true })
-set({ 'n', 'x' }, 'P', '<cmd>lua RemoveClipboardCR()<cr>P', { noremap = true })
-
--- Move lines around
-set('n', '<A-j>', ":m .+1<cr>", { noremap = true })
-set('n', '<A-k>', ":m .-2<cr>", { noremap = true })
-set('v', '<A-j>', ":m '>+1<cr>gv", { noremap = true })
-set('v', '<A-k>', ":m '<-2<cr>gv", { noremap = true })
-
--- Misc
-set({ 'n', 'i' }, '<C-a>', '<Esc>ggVG', { desc = 'Visually Highlight [A]ll' })
-set('i', '<C-H>', '<C-w>', { desc = 'Ctrl + Backspace to delete word' })
-set('n', '<Esc>', '<cmd>nohlsearch<CR>', silent)
-set({ 'i', 'c' }, '<C-v>', paste)
-set('n', '<leader>z', toggle_zen, { desc = '[Z]en Mode', silent = true })
-unbind({ 'i', 'n', 'v' }, '<C-r>')
-
-set('n', 'U', '<cmd>redo<cr>')
-set('i', '<C-z>', '<cmd>undo<cr>')
-set({ 'i', 'n', 'v' }, '<C-q>', '<cmd>wqa<cr>')
-set('n', '<leader>yp', yank_filepath_to_clipboard('linux'), { desc = '[Y]oink File [P]ath (linux)' })
-set('n', '<leader>yP', yank_filepath_to_clipboard('windows'), { desc = '[Y]oink File [P]ath (windows)' })
-
--- Window Navigation - NO NEED BECAUSE IT CONFLICTS WITH TMUX
--- set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
--- set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the down window' })
--- set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the up window' })
--- 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('<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')
-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' })
-
--- Reformats file using lsp
-set('n', '=', vim.lsp.buf.format, { desc = 'Format File' })
diff --git a/.config/nvim/lua/custom/config/language-servers.lua b/.config/nvim/lua/custom/config/language-servers.lua
deleted file mode 100644
index f7e28c1..0000000
--- a/.config/nvim/lua/custom/config/language-servers.lua
+++ /dev/null
@@ -1,155 +0,0 @@
--- NOTE: a table or true to enable, false to disable
-return {
- lua_ls = {
- settings = {
- diagnostics = { globals = { 'vim' } },
- telemetry = { enabled = false },
- hint = { enable = true },
- workspace = {
- library = {
- [vim.fn.expand('$VIMRUNTIME/lua')] = true,
- [vim.fn.stdpath('config') .. '/lua'] = true,
- },
- },
- },
- }, -- lua
- clangd = {
- mason = false,
- cmd = {
- 'clangd',
- '--background-index',
- '--clang-tidy',
- '--header-insertion=iwyu',
- '--completion-style=detailed',
- '--function-arg-placeholders',
- '--fallback-style=llvm',
- },
- root_dir = function(filename)
- return require('lspconfig/util').root_pattern(
- '.clang-tidy',
- '.clang-format',
- 'compile_commands.json',
- '.git'
- )(filename) or vim.fn.getcwd()
- end,
- init_options = {
- usePlaceholders = true,
- completeUnimported = true,
- clangdFileStatus = true,
- },
- }, -- c/cpp
- neocmake = {
- root_dir = function(filename)
- return require('lspconfig/util').root_pattern(
- 'CMakePresets.json',
- 'CTestConfig.cmake',
- 'build',
- 'cmake',
- '.git' -- NOTE: git is last due to monorepos (so it tries to use build/cmake first)
- )(filename) or vim.fn.getcwd()
- end,
- },
- pyright = {
- settings = {
- python = {
- pythonPath = '~/python/venv/bin/python',
- },
- },
- }, -- python
- bashls = true, -- bash
- taplo = true, -- toml
- lemminx = true, -- xml
- yamlls = true, -- yaml
- jsonls = true, -- json
- html = true, -- html
- cssls = true, -- css
- ts_ls = true, -- javascript/typescript
- astro = true, -- astro framework
- mdx_analyzer = true, -- markdown with JS I think
- -- marksman = true, -- Markdown LSP
- markdown_oxide = true, -- Markdown LSP but better
- gopls = {
- cmd = { 'gopls' },
- filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' },
- root_dir = function(filename)
- return require('lspconfig/util').root_pattern('go.work', 'go.mod', '.git')(filename)
- end,
- settings = {
- gopls = {
- gofumpt = true,
- codelenses = {
- gc_details = false,
- generate = true,
- regenerate_cgo = true,
- run_govulncheck = true,
- test = true,
- tidy = true,
- upgrade_dependency = true,
- vendor = true,
- },
- hints = {
- assignVariableTypes = false,
- compositeLiteralFields = false,
- compositeLiteralTypes = true,
- constantValues = true,
- functionTypeParameters = false,
- parameterNames = false,
- rangeVariableTypes = true,
- },
- analyses = {
- fieldalignment = true,
- nilness = true,
- unusedparams = true,
- unusedwrite = true,
- useany = true,
- },
- usePlaceholders = false,
- completeUnimported = true,
- staticcheck = true,
- directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' },
- semanticTokens = true,
- },
- },
- }, -- Go LSP
- jdtls = true, -- java
- -- sqlls = true,
- -- sqls = {
- -- on_attach = function(client, bufnr)
- -- require('sqls').on_attach(client, bufnr)
- -- end,
- -- settings = {
- -- sqls = {
- -- connections = {
- -- {
- -- driver = 'sqlite3',
- -- dataSourceName = '/home/kyren/projects/eko/server.db',
- -- },
- -- },
- -- },
- -- },
- -- },
- zls = {
- mason = false,
- cmd = { 'zls' },
- settings = {
- zls = {
- enable_build_on_save = true,
- build_on_save_args = {},
- enable_argument_placeholders = false,
- warn_style = true,
-
- inlay_hints_show_variable_type_hints = true,
- inlay_hints_show_struct_literal_field_type = true,
- inlay_hints_show_parameter_name = true,
- inlay_hints_show_builtin = true,
- inlay_hints_hide_redundant_param_names = true,
- inlay_hints_hide_redundant_param_names_last_token = true,
- },
- },
- }, -- zig
- nil_ls = {}, -- nix
- asm_lsp = {
- mason = false,
- cmd = { 'asm-lsp' },
- },
-}
diff --git a/.config/nvim/lua/custom/config/lsp-keymaps.lua b/.config/nvim/lua/custom/config/lsp-keymaps.lua
deleted file mode 100644
index 7bbc2e8..0000000
--- a/.config/nvim/lua/custom/config/lsp-keymaps.lua
+++ /dev/null
@@ -1,73 +0,0 @@
-local severity = vim.diagnostic.severity
-local function next_diagnostic(diagnostic_severity)
- return function()
- require('lspsaga.diagnostic'):goto_next({ severity = diagnostic_severity })
- end
-end
-local function prev_diagnostic(diagnostic_severity)
- return function()
- require('lspsaga.diagnostic'):goto_prev({ severity = diagnostic_severity })
- end
-end
-local function cursor_diagnostics()
- vim.diagnostic.open_float({
- scope = 'cursor',
- border = 'single',
- })
-end
-
-local keymaps = {
- { 'n', 'gd', '<cmd>Lspsaga goto_definition<cr>', { desc = '[G]oto [D]efinition' } },
- -- { 'n', 'gu', '<cmd>Telescope lsp_references<cr>', { desc = '[G]oto [U]sages' } },
- { 'n', 'gu', '<cmd>Lspsaga finder<cr>', { desc = '[G]oto [U]sages' } },
- { 'n', 'gi', '<cmd>Telescope lsp_implementations<cr>', { desc = '[G]oto [I]mplementations' } },
- { 'n', 'gt', '<cmd>Telescope lsp_type_definitions<cr>', { desc = '[G]oto [T]ype Definitions' } },
- { 'n', '<leader>ds', '<cmd>Telescope lsp_document_symbols<cr>', { desc = '[D]ocument [S]symbols' } },
- { 'n', '<leader>ps', '<cmd>Telescope lsp_workspace_symbols<cr>', { desc = '[P]roject [S]ymbols' } },
- { { 'n', 'i' }, '<C-p>', vim.lsp.buf.signature_help, { desc = 'Show [P]arameters' } },
- { 'n', 'K', '<cmd>Lspsaga hover_doc<cr>', { desc = 'Documentation' } },
- { 'n', 'R', '<cmd>Lspsaga rename<cr>', { desc = '[R]ename' } },
- { { 'n', 'i' }, '<M-Enter>', '<cmd>Lspsaga code_action<cr>', { desc = 'Code Actions' } },
- { 'n', '<leader>ca', '<cmd>Lspsaga code_action<cr><Esc>', { desc = '[C]ode [A]ctions' } },
- { 'n', '<leader>e', next_diagnostic(severity.ERROR), { desc = 'Goto [E]rror' } },
- { 'n', '<leader>E', prev_diagnostic(severity.ERROR), { desc = 'Goto [E]rror (prev)' } },
- { 'n', '<leader>w', next_diagnostic(severity.WARN), { desc = 'Goto [W]arning' } },
- { 'n', '<leader>W', prev_diagnostic(severity.WARN), { desc = 'Goto [W]arning (prev)' } },
- { 'n', '<leader>D', cursor_diagnostics, { desc = '[D]iagnostics under cursor' } },
-}
-
-for _, ft in ipairs({ 'c', 'h', 'cpp', 'hpp' }) do
- keymaps[ft] = {
- { 'n', 'H', '<cmd>ClangdSwitchSourceHeader<cr>', { desc = '[H]eader and Source Switcher' } },
- { 'n', 'K', '<cmd>lua require("pretty_hover").hover()<cr>', { desc = 'Documentation Hover' } },
- }
-end
-
-local function set_keymaps(tbl, bufnr)
- for _, keymap in ipairs(tbl) do
- local mode = keymap[1]
- local lhs = keymap[2]
- local rhs = keymap[3]
- local opts = keymap[4] or {}
- opts.buffer = bufnr
- vim.keymap.set(mode, lhs, rhs, opts)
- end
-end
-
-local M = {}
-
---- Registers LSP keymaps for the given buffer
----@param bufnr number: the id of the buffer
-M.setup = function(bufnr)
- local filetype = vim.bo[bufnr].filetype
- set_keymaps(keymaps, bufnr)
- for ft, tbl in pairs(keymaps) do
- if type(ft) == 'number' or ft ~= filetype then
- goto continue
- end
- set_keymaps(tbl, bufnr)
- ::continue::
- end
-end
-
-return M
diff --git a/.config/nvim/lua/custom/config/lsp.lua b/.config/nvim/lua/custom/config/lsp.lua
deleted file mode 100644
index 02ff31f..0000000
--- a/.config/nvim/lua/custom/config/lsp.lua
+++ /dev/null
@@ -1,73 +0,0 @@
-local lspconfig = require('lspconfig')
-local capabilities = require('cmp_nvim_lsp').default_capabilities()
-
-local servers = require('custom.config.language-servers')
-for name, config in pairs(servers) do
- if config == false then
- goto continue
- end
- if config == true then
- ---@diagnostic disable-next-line: cast-local-type
- config = {}
- end
-
- -- NOTE: there must be a better way to do it, but it will do for now
- if name == 'markdown_oxide' then
- ---@diagnostic disable-next-line: cast-local-type
- config = vim.tbl_deep_extend('force', {}, {
- capabilities = vim.tbl_deep_extend('force', capabilities, {
- workspace = {
- didChangeWatchedFiles = {
- dynamicRegistration = true,
- },
- },
- }),
- }, config)
- else
- ---@diagnostic disable-next-line: cast-local-type
- config = vim.tbl_deep_extend('force', {}, {
- capabilities = capabilities,
- }, config)
- end
-
- lspconfig[name].setup(config)
- ::continue::
-end
-
-vim.api.nvim_create_autocmd('LspAttach', {
- callback = function(args)
- local bufnr = args.buf
- local client = assert(vim.lsp.get_client_by_id(args.data.client_id), 'must have valid client')
-
- local settings = servers[client.name]
- if type(settings) ~= 'table' then
- ---@diagnostic disable-next-line: cast-local-type
- settings = {}
- end
-
- -- Override server capabilities
- if settings.server_capabilities then
- for k, v in pairs(settings.server_capabilities) do
- if v == vim.NIL then
- v = nil
- end
- client.server_capabilities[k] = v
- end
- end
-
- -- Workaround for semantic tokens apparently?
- -- https://www.lazyvim.org/extras/lang/go
- -- https://github.com/golang/go/issues/54531#issuecomment-1464982242
- if client.name == 'gopls' and not client.server_capabilities.semanticTokensProvider then
- local semantic = client.config.capabilities.textDocument.semanticTokens
- client.server_capabilities.semanticTokensProvider = {
- full = true,
- legend = { tokenModifiers = semantic.tokenModifiers, tokenTypes = semantic.tokenTypes },
- range = true,
- }
- end
-
- -- Register buffer local LSP keymaps
- require('custom.config.lsp-keymaps').setup(bufnr)
- end,
-})
diff --git a/.config/nvim/lua/custom/config/lualine.lua b/.config/nvim/lua/custom/config/lualine.lua
deleted file mode 100644
index 53cd7fe..0000000
--- a/.config/nvim/lua/custom/config/lualine.lua
+++ /dev/null
@@ -1,92 +0,0 @@
-local lualine = require('lualine')
-local lsp_progress = require('lsp-progress')
-
-local progress_filled = '█'
-local progress_empty = '░'
-local function progress_bar(percentage, width)
- -- Ensure i is an integer between 0 and width (inclusive)
- local i = math.max(0, math.min(math.floor(width * percentage), width))
- return string.rep(progress_filled, i) .. string.rep(progress_empty, width - i)
-end
-
-local progress_bar_width = 10
-lsp_progress.setup({
- format = function(client_messages) -- global
- local sign = ' LSP'
- if #client_messages > 0 then
- return sign .. ' ' .. table.concat(client_messages, ' ')
- end
- if #require('lsp-progress.api').lsp_clients() > 0 then
- return sign
- end
- return ''
- end,
- client_format = function(_, _, series_messages) -- per lsp
- return #series_messages > 0 and table.concat(series_messages, ', ') or nil
- end,
- series_format = function(title, message, percentage, done) -- per progress
- local builder = {}
- local has_title = false
- local has_message = false
- if type(title) == 'string' and string.len(title) > 0 then
- table.insert(builder, title .. ':')
- has_title = true
- end
- if percentage then
- table.insert(builder, string.format('%.0f%%', percentage))
- table.insert(builder, 1, progress_bar(percentage / 100, progress_bar_width))
- end
- if type(message) == 'string' and string.len(message) > 0 then
- table.insert(builder, string.format('(%s)', message))
- has_message = true
- end
- if done and (has_title or has_message) then
- table.insert(builder, ' ')
- end
- return table.concat(builder, ' ')
- end,
-})
-
-lualine.setup({
- options = {
- globalstatus = true,
- theme = 'auto',
- },
- sections = {
- lualine_a = { { 'mode', icon = '' } },
- lualine_b = {
- -- require('auto-session.lib').current_session_name,
- { 'branch', icon = '' },
- {
- 'diagnostics',
- symbols = {
- error = '󰅙 ',
- warn = '󰀦 ',
- info = '󰋼 ',
- hint = '󰌵 ',
- },
- },
- },
- lualine_c = {
- function()
- return lsp_progress.progress()
- end,
- },
- lualine_x = {
- 'searchcount',
- 'encoding',
- 'fileformat',
- 'filetype',
- },
- lualine_y = { 'progress' },
- lualine_z = { 'location' },
- },
- extensions = { 'oil', 'trouble' },
-})
-
--- Refresh lualine when lsp progress is updated
-vim.api.nvim_create_autocmd('User', {
- group = vim.api.nvim_create_augroup('lualine_augroup', { clear = true }),
- pattern = 'LspProgressStatusUpdated',
- callback = require('lualine').refresh,
-})
diff --git a/.config/nvim/lua/custom/config/options.lua b/.config/nvim/lua/custom/config/options.lua
deleted file mode 100644
index 3e77e0f..0000000
--- a/.config/nvim/lua/custom/config/options.lua
+++ /dev/null
@@ -1,61 +0,0 @@
--- System
-vim.g.have_nerd_font = true
-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
-vim.opt.exrc = true -- WARNING: runs .nvim.lua in cwd, which may execute arbitrary code
-
--- 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
-
--- UI
-vim.opt.colorcolumn = '80'
-vim.opt.signcolumn = 'auto:9'
-vim.opt.number = true
-vim.opt.relativenumber = true
-vim.opt.cursorline = true -- highlight current line
-vim.opt.splitright = true
-vim.opt.splitbelow = true
-vim.opt.showmode = false -- don't show mode, because lualine already does
-vim.opt.list = true
-vim.opt.listchars = { tab = ' ', trail = '·', nbsp = '␣' }
-vim.diagnostic.config({ signs = false }) -- disable signcolumn diagnostics
-vim.opt.fillchars:append({ diff = '╱' }) -- nicer diff view for filled spaces
-
--- Searching
-vim.opt.hlsearch = true
-vim.opt.ignorecase = true
-vim.opt.smartcase = true
-
--- Misc
-vim.opt_local.wrap = false
-vim.opt.wrap = false
-vim.opt.scrolloff = 8
-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
-
--- Disable warnings for missing language providers
-vim.g.loaded_node_provider = 0
-vim.g.loaded_perl_provider = 0
-vim.g.loaded_ruby_provider = 0
-vim.g.loaded_python3_provider = 0
-
--- LSP
-vim.lsp.inlay_hint.enable()
-vim.diagnostic.config({ virtual_text = false, update_in_insert = true })
-
--- Add support for mdx files
-vim.filetype.add({
- extension = {
- mdx = 'markdown',
- },
-})
-
--- Zig LSP settings
-vim.g.zig_fmt_parse_errors = 0
-vim.g.zig_fmt_autosave = 0
diff --git a/.config/nvim/lua/custom/config/rustaceanvim.lua b/.config/nvim/lua/custom/config/rustaceanvim.lua
deleted file mode 100644
index 91b1092..0000000
--- a/.config/nvim/lua/custom/config/rustaceanvim.lua
+++ /dev/null
@@ -1,37 +0,0 @@
----@type RustaceanOpts
-vim.g.rustaceanvim = {
- ---@type RustaceanToolsOpts
- tools = {
- float_win_config = {
- border = 'rounded',
- },
- },
- ---@type RustaceanLspClientOpts
- server = {
- on_attach = function(_, bufnr)
- local keymaps = {
- { { 'n', 'i' }, '<M-Enter>', '<cmd>RustLsp codeAction<cr>', { desc = 'Code Action' } },
- }
-
- for _, keymap in ipairs(keymaps) do
- local modes = keymap[1]
- local lhs = keymap[2]
- local rhs = keymap[3]
- local opts = keymap[4]
- opts.buffer = bufnr
-
- vim.keymap.set(modes, lhs, rhs, opts)
- end
- end,
- default_settings = {
- ['rust-analyzer'] = {
- semanticHighlighting = {
- operator = { specialization = { enable = true } },
- punctuation = { enable = true, specialization = { enable = true } },
- },
- },
- },
- },
- ---@type RustaceanDapOpts
- dap = {},
-}
diff --git a/.config/nvim/lua/custom/config/telescope.lua b/.config/nvim/lua/custom/config/telescope.lua
deleted file mode 100644
index 5a84121..0000000
--- a/.config/nvim/lua/custom/config/telescope.lua
+++ /dev/null
@@ -1,41 +0,0 @@
-local telescope = require('telescope')
-telescope.setup({
- pickers = {
- find_files = { follow = true, hidden = true },
- grep_string = { additional_args = '--follow' },
- live_grep = { additional_args = '--follow' },
- },
- extensions = {
- fzf = {
- fuzzy = true, -- false will only do exact matching
- override_generic_sorter = true,
- override_file_sorter = true,
- case_mode = 'smart_case', -- default "smart_case" or "ignore_case" or "respect_case"
- },
- ['ui-select'] = {
- require('telescope.themes').get_dropdown({}),
- },
- },
-})
-
-pcall(telescope.load_extension('ui-select'))
-pcall(telescope.load_extension('fzf'))
-
-local builtin = require('telescope.builtin')
-local function find_all()
- builtin.find_files({
- cwd = '~',
- hidden = true,
- no_ignore = true,
- no_ignore_parent = true,
- })
-end
-
-vim.keymap.set('n', '<leader>fs', builtin.find_files, { desc = '[F]ile [S]ystem' })
-vim.keymap.set('n', '<leader>fa', find_all, { desc = '[F]ind [A]ll files' })
-vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = '[F]ind [H]elp' })
-vim.keymap.set('n', '<leader>fm', builtin.man_pages, { desc = '[F]ind [M]an Pages' })
-vim.keymap.set('n', '<leader>lv', builtin.live_grep, { desc = '[L]ive [G]rep' })
-vim.keymap.set('n', '<leader>f.', builtin.oldfiles, { desc = '[F]ind Recent Files' })
-vim.keymap.set('n', '<leader>th', builtin.colorscheme, { desc = 'List [Th]eme' })
-vim.keymap.set('n', '<leader>hi', builtin.highlights, { desc = '[Hi]light Groups' })