diff --git a/nvim/ftplugin/java.lua b/nvim/ftplugin/java.lua index 39be021..38cfd50 100644 --- a/nvim/ftplugin/java.lua +++ b/nvim/ftplugin/java.lua @@ -8,6 +8,11 @@ local root_files = { 'Main.java', } +-- Tab Width +vim.bo.tabstop = 4 +vim.bo.shiftwidth = 4 +vim.bo.expandtab = true + vim.lsp.start { name = 'jdtls', cmd = { 'jdtls' }, diff --git a/nvim/init.lua b/nvim/init.lua index edd215d..d683213 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -7,6 +7,8 @@ local g = vim.g g.mapleader = ' ' g.maplocalleader = ' ' +vim.cmd('let g:telescope_debug = 1') + opt.compatible = false -- Enable true colour support @@ -31,9 +33,9 @@ opt.spell = true opt.spelllang = 'en' opt.expandtab = true -opt.tabstop = 4 -opt.softtabstop = 4 -opt.shiftwidth = 4 +opt.tabstop = 2 +opt.softtabstop = 2 +opt.shiftwidth = 2 opt.foldenable = true opt.history = 2000 opt.nrformats = 'bin,hex' -- 'octal' @@ -44,14 +46,6 @@ opt.cmdheight = 0 opt.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] --- Restore cursor position -vim.api.nvim_create_autocmd({ 'BufReadPost' }, { - pattern = { '*' }, - callback = function() - vim.api.nvim_exec2('silent! normal! g`"zv', { output = false }) - end, -}) - -- Configure Neovim diagnostic messages local function prefix_diagnostic(prefix, diagnostic) diff --git a/nvim/plugin/autocommands.lua b/nvim/plugin/autocommands.lua index 64d6f0c..27acc12 100644 --- a/nvim/plugin/autocommands.lua +++ b/nvim/plugin/autocommands.lua @@ -24,6 +24,14 @@ api.nvim_create_autocmd('TermOpen', { end, }) +-- Restore cursor position +vim.api.nvim_create_autocmd({ 'BufReadPost' }, { + pattern = { '*' }, + callback = function() + vim.api.nvim_exec2('silent! normal! g`"zv', { output = false }) + end, +}) + -- LSP local keymap = vim.keymap diff --git a/nvim/plugin/conform.lua b/nvim/plugin/conform.lua index 1cf6600..d091ea5 100644 --- a/nvim/plugin/conform.lua +++ b/nvim/plugin/conform.lua @@ -2,7 +2,6 @@ require('conform').setup { formatters_by_ft = { lua = { 'stylua' }, nix = { 'alejandra' }, - -- java = { "google-java-format" }, -- Conform will run multiple formatters sequentially -- python = { "isort", "black" }, -- You can customize some of the format options for the filetype (:help conform.format) diff --git a/nvim/plugin/copilot.lua b/nvim/plugin/copilot.lua index e51701b..e36957e 100644 --- a/nvim/plugin/copilot.lua +++ b/nvim/plugin/copilot.lua @@ -1,15 +1,15 @@ -- Copilot related plugins setup -require('CopilotChat').setup { - debug = true, -} - -require('copilot_cmp').setup() - -require('copilot').setup { - suggestion = { enabled = false }, - panel = { enabled = false }, - filetypes = { - ['*'] = false, - }, - copilot_node_command = 'node', -} +-- require('CopilotChat').setup { +-- debug = true, +-- } +-- +-- require('copilot_cmp').setup() +-- +-- require('copilot').setup { +-- suggestion = { enabled = false }, +-- panel = { enabled = false }, +-- filetypes = { +-- ['*'] = false, +-- }, +-- copilot_node_command = 'node', +-- } diff --git a/nvim/plugin/keymaps.lua b/nvim/plugin/keymaps.lua index ae30f90..5980464 100644 --- a/nvim/plugin/keymaps.lua +++ b/nvim/plugin/keymaps.lua @@ -3,10 +3,7 @@ if vim.g.did_load_keymaps_plugin then end vim.g.did_load_keymaps_plugin = true -local api = vim.api -local fn = vim.fn local keymap = vim.keymap -local diagnostic = vim.diagnostic -- Yank from current position till end of current line keymap.set('n', 'Y', 'y$', { silent = true, desc = '[Y]ank to end of line' }) @@ -17,168 +14,10 @@ keymap.set('n', ']b', vim.cmd.bnext, { silent = true, desc = 'next [b]uffer' }) keymap.set('n', '[B', vim.cmd.bfirst, { silent = true, desc = 'first [B]uffer' }) keymap.set('n', ']B', vim.cmd.blast, { silent = true, desc = 'last [B]uffer' }) --- Toggle the quickfix list (only opens if it is populated) -local function toggle_qf_list() - local qf_exists = false - for _, win in pairs(fn.getwininfo() or {}) do - if win['quickfix'] == 1 then - qf_exists = true - end - end - if qf_exists == true then - vim.cmd.cclose() - return - end - if not vim.tbl_isempty(vim.fn.getqflist()) then - vim.cmd.copen() - end -end - -keymap.set('n', '', toggle_qf_list, { desc = 'toggle quickfix list' }) - -local function try_fallback_notify(opts) - local success, _ = pcall(opts.try) - if success then - return - end - success, _ = pcall(opts.fallback) - if success then - return - end - vim.notify(opts.notify, vim.log.levels.INFO) -end - --- Cycle the quickfix and location lists -local function cleft() - try_fallback_notify { - try = vim.cmd.cprev, - fallback = vim.cmd.clast, - notify = 'Quickfix list is empty!', - } -end - -local function cright() - try_fallback_notify { - try = vim.cmd.cnext, - fallback = vim.cmd.cfirst, - notify = 'Quickfix list is empty!', - } -end - -keymap.set('n', '[c', cleft, { silent = true, desc = '[c]ycle quickfix left' }) -keymap.set('n', ']c', cright, { silent = true, desc = '[c]ycle quickfix right' }) -keymap.set('n', '[C', vim.cmd.cfirst, { silent = true, desc = 'first quickfix entry' }) -keymap.set('n', ']C', vim.cmd.clast, { silent = true, desc = 'last quickfix entry' }) - -local function lleft() - try_fallback_notify { - try = vim.cmd.lprev, - fallback = vim.cmd.llast, - notify = 'Location list is empty!', - } -end - -local function lright() - try_fallback_notify { - try = vim.cmd.lnext, - fallback = vim.cmd.lfirst, - notify = 'Location list is empty!', - } -end - -keymap.set('n', '[l', lleft, { silent = true, desc = 'cycle [l]oclist left' }) -keymap.set('n', ']l', lright, { silent = true, desc = 'cycle [l]oclist right' }) -keymap.set('n', '[L', vim.cmd.lfirst, { silent = true, desc = 'first [L]oclist entry' }) -keymap.set('n', ']L', vim.cmd.llast, { silent = true, desc = 'last [L]oclist entry' }) - --- Resize vertical splits -local toIntegral = math.ceil -keymap.set('n', 'w+', function() - local curWinWidth = api.nvim_win_get_width(0) - api.nvim_win_set_width(0, toIntegral(curWinWidth * 3 / 2)) -end, { silent = true, desc = 'inc window [w]idth' }) -keymap.set('n', 'w-', function() - local curWinWidth = api.nvim_win_get_width(0) - api.nvim_win_set_width(0, toIntegral(curWinWidth * 2 / 3)) -end, { silent = true, desc = 'dec window [w]idth' }) -keymap.set('n', 'h+', function() - local curWinHeight = api.nvim_win_get_height(0) - api.nvim_win_set_height(0, toIntegral(curWinHeight * 3 / 2)) -end, { silent = true, desc = 'inc window [h]eight' }) -keymap.set('n', 'h-', function() - local curWinHeight = api.nvim_win_get_height(0) - api.nvim_win_set_height(0, toIntegral(curWinHeight * 2 / 3)) -end, { silent = true, desc = 'dec window [h]eight' }) - --- Close floating windows [Neovim 0.10 and above] -keymap.set('n', 'fq', function() - vim.cmd('fclose!') -end, { silent = true, desc = '[f]loating windows: [q]uit/close all' }) - -- Remap Esc to switch to normal mode and Ctrl-Esc to pass Esc to terminal keymap.set('t', '', '', { desc = 'switch to normal mode' }) keymap.set('t', '', '', { desc = 'send Esc to terminal' }) --- Shortcut for expanding to current buffer's directory in command mode -keymap.set('c', '%%', function() - if fn.getcmdtype() == ':' then - return fn.expand('%:h') .. '/' - else - return '%%' - end -end, { expr = true, desc = "expand to current buffer's directory" }) - -keymap.set('n', 'tn', vim.cmd.tabnew, { desc = '[t]ab: [n]ew' }) -keymap.set('n', 'tq', vim.cmd.tabclose, { desc = '[t]ab: [q]uit/close' }) - -local severity = diagnostic.severity - -keymap.set('n', 'e', function() - local _, winid = diagnostic.open_float(nil, { scope = 'line' }) - if not winid then - vim.notify('no diagnostics found', vim.log.levels.INFO) - return - end - vim.api.nvim_win_set_config(winid or 0, { focusable = true }) -end, { noremap = true, silent = true, desc = 'diagnostics floating window' }) -keymap.set('n', '[d', diagnostic.goto_prev, { noremap = true, silent = true, desc = 'previous [d]iagnostic' }) -keymap.set('n', ']d', diagnostic.goto_next, { noremap = true, silent = true, desc = 'next [d]iagnostic' }) -keymap.set('n', '[e', function() - diagnostic.goto_prev { - severity = severity.ERROR, - } -end, { noremap = true, silent = true, desc = 'previous [e]rror diagnostic' }) -keymap.set('n', ']e', function() - diagnostic.goto_next { - severity = severity.ERROR, - } -end, { noremap = true, silent = true, desc = 'next [e]rror diagnostic' }) -keymap.set('n', '[w', function() - diagnostic.goto_prev { - severity = severity.WARN, - } -end, { noremap = true, silent = true, desc = 'previous [w]arning diagnostic' }) -keymap.set('n', ']w', function() - diagnostic.goto_next { - severity = severity.WARN, - } -end, { noremap = true, silent = true, desc = 'next [w]arning diagnostic' }) -keymap.set('n', '[h', function() - diagnostic.goto_prev { - severity = severity.HINT, - } -end, { noremap = true, silent = true, desc = 'previous [h]int diagnostic' }) -keymap.set('n', ']h', function() - diagnostic.goto_next { - severity = severity.HINT, - } -end, { noremap = true, silent = true, desc = 'next [h]int diagnostic' }) - -keymap.set('n', '', 'zz', { desc = 'move [d]own half-page and center' }) -keymap.set('n', '', 'zz', { desc = 'move [u]p half-page and center' }) -keymap.set('n', '', 'zz', { desc = 'move DOWN [f]ull-page and center' }) -keymap.set('n', '', 'zz', { desc = 'move UP full-page and center' }) - -- DAP Keymaps vim.api.nvim_set_keymap( 'n', diff --git a/nvim/plugin/telescope.lua b/nvim/plugin/telescope.lua index 60426a7..c199cca 100644 --- a/nvim/plugin/telescope.lua +++ b/nvim/plugin/telescope.lua @@ -21,18 +21,12 @@ local layout_config = { }, } -vim.keymap.set('n', 'tp', function() - builtin.find_files() -end, { desc = '[t]elescope find files - ctrl[p] style' }) -vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) -vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) telescope.setup { diff --git a/nvim/plugin/which-key.lua b/nvim/plugin/which-key.lua index d81bdb9..9d4fb51 100644 --- a/nvim/plugin/which-key.lua +++ b/nvim/plugin/which-key.lua @@ -2,7 +2,7 @@ require('which-key').setup() -- local whichkey = require('which-key') -- -- whichkey.setup() - +-- -- whichkey.add { -- { 'c', group = '[C]ode' }, -- { 'd', group = '[D]ocument' },