My changes
This commit is contained in:
parent
e6710a461a
commit
ac1dcf733a
|
@ -0,0 +1,5 @@
|
||||||
|
local config = {
|
||||||
|
cmd = { '/usr/bin/jdtls' },
|
||||||
|
root_dir = vim.fs.dirname(vim.fs.find({ 'gradlew', '.git', 'mvnw' }, { upward = true })[1]),
|
||||||
|
}
|
||||||
|
require('jdtls').start_or_attach(config)
|
254
init.lua
254
init.lua
|
@ -110,7 +110,7 @@ vim.opt.showmode = false
|
||||||
-- Sync clipboard between OS and Neovim.
|
-- Sync clipboard between OS and Neovim.
|
||||||
-- Remove this option if you want your OS clipboard to remain independent.
|
-- Remove this option if you want your OS clipboard to remain independent.
|
||||||
-- See `:help 'clipboard'`
|
-- See `:help 'clipboard'`
|
||||||
vim.opt.clipboard = 'unnamedplus'
|
-- vim.opt.clipboard = 'unnamedplus'
|
||||||
|
|
||||||
-- Enable break indent
|
-- Enable break indent
|
||||||
vim.opt.breakindent = true
|
vim.opt.breakindent = true
|
||||||
|
@ -242,6 +242,7 @@ require('lazy').setup {
|
||||||
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
|
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||||
'lewis6991/gitsigns.nvim',
|
'lewis6991/gitsigns.nvim',
|
||||||
opts = {
|
opts = {
|
||||||
|
-- See `:help gitsigns.txt`
|
||||||
signs = {
|
signs = {
|
||||||
add = { text = '+' },
|
add = { text = '+' },
|
||||||
change = { text = '~' },
|
change = { text = '~' },
|
||||||
|
@ -249,6 +250,66 @@ require('lazy').setup {
|
||||||
topdelete = { text = '‾' },
|
topdelete = { text = '‾' },
|
||||||
changedelete = { text = '~' },
|
changedelete = { text = '~' },
|
||||||
},
|
},
|
||||||
|
on_attach = function(bufnr)
|
||||||
|
local gs = package.loaded.gitsigns
|
||||||
|
|
||||||
|
local function map(mode, l, r, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.buffer = bufnr
|
||||||
|
vim.keymap.set(mode, l, r, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Navigation
|
||||||
|
map({ 'n', 'v' }, ']c', function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return ']c'
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
gs.next_hunk()
|
||||||
|
end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, { expr = true, desc = 'Jump to next hunk' })
|
||||||
|
|
||||||
|
map({ 'n', 'v' }, '[c', function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return '[c'
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
gs.prev_hunk()
|
||||||
|
end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, { expr = true, desc = 'Jump to previous hunk' })
|
||||||
|
|
||||||
|
-- Actions
|
||||||
|
-- visual mode
|
||||||
|
map('v', '<leader>hs', function()
|
||||||
|
gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
|
||||||
|
end, { desc = 'stage git hunk' })
|
||||||
|
map('v', '<leader>hr', function()
|
||||||
|
gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
|
||||||
|
end, { desc = 'reset git hunk' })
|
||||||
|
-- normal mode
|
||||||
|
map('n', '<leader>hs', gs.stage_hunk, { desc = 'git stage hunk' })
|
||||||
|
map('n', '<leader>hr', gs.reset_hunk, { desc = 'git reset hunk' })
|
||||||
|
map('n', '<leader>hS', gs.stage_buffer, { desc = 'git Stage buffer' })
|
||||||
|
map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
|
||||||
|
map('n', '<leader>hR', gs.reset_buffer, { desc = 'git Reset buffer' })
|
||||||
|
map('n', '<leader>hp', gs.preview_hunk, { desc = 'preview git hunk' })
|
||||||
|
map('n', '<leader>hb', function()
|
||||||
|
gs.blame_line { full = false }
|
||||||
|
end, { desc = 'git blame line' })
|
||||||
|
map('n', '<leader>hd', gs.diffthis, { desc = 'git diff against index' })
|
||||||
|
map('n', '<leader>hD', function()
|
||||||
|
gs.diffthis '~'
|
||||||
|
end, { desc = 'git diff against last commit' })
|
||||||
|
|
||||||
|
-- Toggles
|
||||||
|
map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
|
||||||
|
map('n', '<leader>td', gs.toggle_deleted, { desc = 'toggle git show deleted' })
|
||||||
|
|
||||||
|
-- Text object
|
||||||
|
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -372,6 +433,14 @@ require('lazy').setup {
|
||||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||||
|
local function telescope_find_files_in_home()
|
||||||
|
local opts = {
|
||||||
|
hidden = true,
|
||||||
|
cwd = '/home/julian',
|
||||||
|
}
|
||||||
|
require('telescope.builtin').find_files(opts)
|
||||||
|
end
|
||||||
|
vim.keymap.set('n', '<leader>sc', telescope_find_files_in_home, { desc = '[S]earch files starting in ~' })
|
||||||
|
|
||||||
-- Slightly advanced example of overriding default behavior and theme
|
-- Slightly advanced example of overriding default behavior and theme
|
||||||
vim.keymap.set('n', '<leader>/', function()
|
vim.keymap.set('n', '<leader>/', function()
|
||||||
|
@ -726,7 +795,7 @@ require('lazy').setup {
|
||||||
priority = 1000, -- make sure to load this before all the other start plugins
|
priority = 1000, -- make sure to load this before all the other start plugins
|
||||||
config = function()
|
config = function()
|
||||||
-- Load the colorscheme here
|
-- Load the colorscheme here
|
||||||
vim.cmd.colorscheme 'tokyonight-night'
|
vim.cmd.colorscheme 'onedark'
|
||||||
|
|
||||||
-- You can configure highlights by doing something like
|
-- You can configure highlights by doing something like
|
||||||
vim.cmd.hi 'Comment gui=none'
|
vim.cmd.hi 'Comment gui=none'
|
||||||
|
@ -781,7 +850,28 @@ require('lazy').setup {
|
||||||
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' },
|
ensure_installed = {
|
||||||
|
'lua',
|
||||||
|
'python',
|
||||||
|
'tsx',
|
||||||
|
'javascript',
|
||||||
|
'typescript',
|
||||||
|
'vimdoc',
|
||||||
|
'vim',
|
||||||
|
'bash',
|
||||||
|
'css',
|
||||||
|
'dockerfile',
|
||||||
|
'html',
|
||||||
|
'java',
|
||||||
|
'kotlin',
|
||||||
|
'json',
|
||||||
|
'markdown_inline',
|
||||||
|
'ruby',
|
||||||
|
'sql',
|
||||||
|
'toml',
|
||||||
|
'vue',
|
||||||
|
'yaml',
|
||||||
|
},
|
||||||
-- Autoinstall languages that are not installed
|
-- Autoinstall languages that are not installed
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
|
@ -796,6 +886,75 @@ require('lazy').setup {
|
||||||
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
-- live autocompletion for commands etc
|
||||||
|
{ 'gelguy/wilder.nvim', version = '*', config = function() end },
|
||||||
|
-- File browser
|
||||||
|
{
|
||||||
|
'nvim-neo-tree/neo-tree.nvim',
|
||||||
|
version = '*',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-lua/plenary.nvim',
|
||||||
|
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
|
||||||
|
'MunifTanjim/nui.nvim',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('neo-tree').setup {}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- Markdown preview
|
||||||
|
{
|
||||||
|
'iamcco/markdown-preview.nvim',
|
||||||
|
ft = 'markdown',
|
||||||
|
-- build = "cd app && yarn install", -- after removing Joplin one day
|
||||||
|
build = 'cd app && npm install',
|
||||||
|
init = function()
|
||||||
|
vim.g.mkdp_filetypes = { 'markdown' }
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- show notifications etc in a nice area
|
||||||
|
{ 'folke/noice.nvim', event = 'VeryLazy', opts = {}, dependencies = {
|
||||||
|
'MunifTanjim/nui.nvim',
|
||||||
|
'rcarriga/nvim-notify',
|
||||||
|
} },
|
||||||
|
{
|
||||||
|
-- Highlight, edit, and navigate code
|
||||||
|
'ThePrimeagen/harpoon',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-lua/plenary.nvim',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'mbbill/undotree',
|
||||||
|
'github/copilot.vim',
|
||||||
|
'mfussenegger/nvim-jdtls',
|
||||||
|
'AckslD/nvim-neoclip.lua',
|
||||||
|
{
|
||||||
|
-- Theme inspired by Atom
|
||||||
|
'navarasu/onedark.nvim',
|
||||||
|
priority = 1000,
|
||||||
|
lazy = false,
|
||||||
|
config = function()
|
||||||
|
require('onedark').setup {
|
||||||
|
-- Set a style preset. 'dark' is default.
|
||||||
|
style = 'dark', -- dark, darker, cool, deep, warm, warmer, light
|
||||||
|
}
|
||||||
|
require('onedark').load()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
-- Set lualine as statusline
|
||||||
|
'nvim-lualine/lualine.nvim',
|
||||||
|
-- See `:help lualine.txt`
|
||||||
|
opts = {
|
||||||
|
options = {
|
||||||
|
icons_enabled = false,
|
||||||
|
theme = 'auto',
|
||||||
|
component_separators = '|',
|
||||||
|
section_separators = '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- tmux vim keybindings
|
||||||
|
'christoomey/vim-tmux-navigator',
|
||||||
|
|
||||||
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
||||||
-- init.lua. If you want these files, they are in the repository, so you can just download them and
|
-- init.lua. If you want these files, they are in the repository, so you can just download them and
|
||||||
|
@ -819,3 +978,92 @@ require('lazy').setup {
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|
||||||
|
-- Toggle line numbers depending on the vim mode
|
||||||
|
local augroup = vim.api.nvim_create_augroup('numbertoggle', {})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufEnter', 'FocusGained', 'InsertLeave', 'CmdlineLeave', 'WinEnter' }, {
|
||||||
|
pattern = '*',
|
||||||
|
group = augroup,
|
||||||
|
callback = function()
|
||||||
|
if vim.o.nu and vim.api.nvim_get_mode().mode ~= 'i' then
|
||||||
|
vim.opt.relativenumber = true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufLeave', 'FocusLost', 'InsertEnter', 'CmdlineEnter', 'WinLeave' }, {
|
||||||
|
pattern = '*',
|
||||||
|
group = augroup,
|
||||||
|
callback = function()
|
||||||
|
if vim.o.nu then
|
||||||
|
vim.opt.relativenumber = false
|
||||||
|
vim.cmd 'redraw'
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set('i', 'jj', '<esc>', { desc = 'Closes insert mode' })
|
||||||
|
vim.keymap.set('n', 'ec', ':', { desc = 'Execute command' })
|
||||||
|
|
||||||
|
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { desc = 'Move line down' })
|
||||||
|
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv", { desc = 'Move line up' })
|
||||||
|
|
||||||
|
vim.keymap.set('x', '<leader>p', '"_dP', { desc = '[P]aste with previous still in buffer' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>y', '"+y', { desc = '[Y]ank to system clipboard' })
|
||||||
|
vim.keymap.set('v', '<leader>y', '"+y', { desc = '[Y]ank to system clipboard' })
|
||||||
|
vim.keymap.set('n', '<leader>Y', '"+Y', { desc = '[Y]ank to system clipboard' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>rr', [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], { desc = '[R]ename by [R]egex pattern' })
|
||||||
|
|
||||||
|
-- map capital b and e to end/start line, should be default?
|
||||||
|
vim.keymap.set('n', 'B', '_', { desc = 'Jump to line [B]eginning' })
|
||||||
|
vim.keymap.set('n', 'E', '$', { desc = 'Jump to line [E]nding' })
|
||||||
|
|
||||||
|
-- wilder
|
||||||
|
local wilder = require 'wilder'
|
||||||
|
wilder.setup { modes = { ':', '/', '?' } }
|
||||||
|
|
||||||
|
-- filetree
|
||||||
|
-- Unless you are still migrating, remove the deprecated commands from v1.x
|
||||||
|
vim.cmd [[ let g:neo_tree_remove_legacy_commands = 1 ]]
|
||||||
|
|
||||||
|
-- neo_tree
|
||||||
|
vim.keymap.set('n', '<leader>n', '<Cmd>Neotree toggle <Cr>', { desc = 'Toggle [N]eoTree' })
|
||||||
|
vim.keymap.set('n', '<leader>m', '<Cmd>Neotree float dir=%:p:h:h reveal_file=%:p <CR>', { desc = '[M]odify File NeoTree' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<C-P>', ':Telescope find_files<CR>', { desc = 'Toggle [N]eoTree' })
|
||||||
|
|
||||||
|
-- harpoon
|
||||||
|
local mark = require 'harpoon.mark'
|
||||||
|
local ui = require 'harpoon.ui'
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>hh', mark.add_file, { desc = 'Add file to harpoon' })
|
||||||
|
vim.keymap.set('n', '<C-e>', ui.toggle_quick_menu, { desc = 'Toggle harpoon quick menu' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<C-t>', function()
|
||||||
|
ui.nav_file(1)
|
||||||
|
end, { desc = 'Harpoon file 1' })
|
||||||
|
vim.keymap.set('n', '<C-n>', function()
|
||||||
|
ui.nav_file(2)
|
||||||
|
end, { desc = 'Harpoon file 2' })
|
||||||
|
|
||||||
|
-- ctrl+s write
|
||||||
|
vim.api.nvim_set_keymap('n', '<C-s>', ':w<CR>', { noremap = true, silent = true })
|
||||||
|
vim.api.nvim_set_keymap('i', '<C-s>', '<Esc>:w<CR>i', { noremap = true, silent = true })
|
||||||
|
|
||||||
|
--- ctrl+q quit
|
||||||
|
vim.api.nvim_set_keymap('n', '<C-q>', ':q<CR>', { noremap = true, silent = true })
|
||||||
|
vim.api.nvim_set_keymap('i', '<C-q>', '<Esc>:q<CR>', { noremap = true, silent = true })
|
||||||
|
|
||||||
|
-- undotree
|
||||||
|
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle, { desc = 'Toggle Undotree' })
|
||||||
|
|
||||||
|
-- copilot disabled by default, enable it by typing :let b:copilot_enabled = 1 or executing ThisIsYourCaptainSpeaking
|
||||||
|
vim.g.copilot_assume_mapped = true
|
||||||
|
vim.api.nvim_exec([[ au BufNewFile,BufRead * let b:copilot_enabled = 0 ]], false)
|
||||||
|
vim.api.nvim_create_user_command('ThisIsYourCaptainSpeaking', 'let b:copilot_enabled = 1', {})
|
||||||
|
|
||||||
|
require('neoclip').setup()
|
||||||
|
vim.api.nvim_set_keymap('n', '<leader>cc', ':Telescope neoclip<CR>', { noremap = true, silent = true })
|
||||||
|
|
Loading…
Reference in New Issue