1
0

Removing Which-key, adding a bunch of small improvments

Highlight on yank
gitsigns
oil as default explorer
This commit is contained in:
Nigel Barink 2024-10-06 17:04:11 +02:00
parent bd1e208133
commit a6c0657d70
Signed by: Nigel
GPG Key ID: 6893A31C2D84A9D2
9 changed files with 289 additions and 244 deletions

View File

@ -9,6 +9,7 @@
"conform.nvim": { "branch": "master", "commit": "1a99fdc1d3aa9ccdf3021e67982a679a8c5c740c" }, "conform.nvim": { "branch": "master", "commit": "1a99fdc1d3aa9ccdf3021e67982a679a8c5c740c" },
"edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" }, "edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" },
"fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" },
"friendly-snippets": { "branch": "main", "commit": "00ba9dd3df89509f95437b8d595553707c46d5ea" },
"git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" }, "git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" },
"gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" }, "gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },

View File

@ -12,4 +12,13 @@ if not vim.loop.fs_stat(lazypath) then
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("barink.keys") require("barink.keys")
require("lazy").setup("barink.plugins") require("lazy").setup("barink.plugins" , {
root = vim.fn.stdpath("data") .. "/lazy", -- directory where plugins will be installed
-- leave nil when passing the spec as the first argument to setup()
change_detection = {
-- automatically check for config file changes and reload the ui
enabled = false,
notify = true, -- get a notification when changes are found
},
})

View File

@ -5,34 +5,42 @@ vim.keymap.set('n', '<leader><F8>', vim.cmd.UndotreeToggle)
vim.keymap.set('n', '<leader>p', [["_dP]]) vim.keymap.set('n', '<leader>p', [["_dP]])
vim.keymap.set('n', '<leader>fa', vim.lsp.buf.format) vim.keymap.set('n', '<leader>fa', vim.lsp.buf.format)
vim.keymap.set('n', '<leader>m', ":Mason<CR>") vim.keymap.set('n', '<leader>m', ":Mason<CR>")
vim.keymap.set('n', '<leader>e',':Explore<CR>', {noremap = false, silent=true}) vim.keymap.set('n', '<leader>e', ':Explore<CR>', { noremap = false, silent = true })
vim.keymap.set('n', '<leader>le',':Lexplore<CR>', {noremap = false, silent=true}) vim.keymap.set('n', '<leader>le', ':Lexplore<CR>', { noremap = false, silent = true })
vim.keymap.set('n', '<leader>l', ':Neotree<CR>', {noremap = false, silent= true}) vim.keymap.set('n', '<leader>l', ':Neotree<CR>', { noremap = false, silent = true })
-- Move lines while in visual mode -- Move lines while in visual mode
vim.keymap.set('v', '<A-S-j>', ':m \'>+1<CR>gv=gv', {noremap = true}) vim.keymap.set('v', '<A-S-j>', ':m \'>+1<CR>gv=gv', { noremap = true })
vim.keymap.set('v', '<A-S-k>', ':m \'<-2<CR>gv=gv', {noremap = true}) vim.keymap.set('v', '<A-S-k>', ':m \'<-2<CR>gv=gv', { noremap = true })
-- Move lines while in normal mode -- Move lines while in normal mode
vim.keymap.set('n', '<A-S-j>', ':m .+1<CR>==', {noremap = true}) vim.keymap.set('n', '<A-S-j>', ':m .+1<CR>==', { noremap = true })
vim.keymap.set('n', '<A-S-k>', ':m .-2<CR>==', {noremap = true}) vim.keymap.set('n', '<A-S-k>', ':m .-2<CR>==', { noremap = true })
-- Move line in edit mode -- Move line in edit mode
vim.keymap.set('i', '<A-j>', ':m .+1<CR>==gi', {noremap = true}) vim.keymap.set('i', '<A-j>', ':m .+1<CR>==gi', { noremap = true })
vim.keymap.set('i', '<A-k>', ':m .-2<CR>==gi', {noremap = true}) vim.keymap.set('i', '<A-k>', ':m .-2<CR>==gi', { noremap = true })
-- Simplified split navigation
vim.keymap.set('n', '<C-h>', '<C-w><C-h>')
vim.keymap.set('n', '<C-j>', '<C-w><C-j>')
vim.keymap.set('n', '<C-k>', '<C-w><C-k>')
vim.keymap.set('n', '<C-l>', '<C-w><C-l>')
-- Diagnostics ! -- Diagnostics !
vim.keymap.set('n', '<C-T>', function() require('trouble').toggle('diagnostics') end ) vim.keymap.set('n', '<C-T>', function() require('trouble').toggle('diagnostics') end)
vim.keymap.set('n', '<leader>d', function () vim.diagnostic.open_float() end ) vim.keymap.set('n', '<leader>d', function() vim.diagnostic.open_float() end)
vim.keymap.set('n', '<leader>dn', function () vim.diagnostic.goto_next() end ) vim.keymap.set('n', '<leader>dn', function() vim.diagnostic.goto_next() end)
vim.keymap.set('n', '<leader>dp', function () vim.diagnostic.goto_prev() end ) vim.keymap.set('n', '<leader>dp', function() vim.diagnostic.goto_prev() end)
vim.keymap.set('n', '<leader>ca', function () vim.lsp.buf.code_action() end) vim.keymap.set('n', '<leader>ca', function() vim.lsp.buf.code_action() end)
-- Debugging -- Debugging
vim.keymap.set('n', '<leader>b', function () require('dap').toggle_breakpoint() end ) vim.keymap.set('n', '<leader>b', function() require('dap').toggle_breakpoint() end)
vim.keymap.set('n', '<F5>', function () print("Start debug session" ) require('dap').continue() end ) vim.keymap.set('n', '<F5>', function()
vim.keymap.set('n', '<F6>', function () require('dap').step_over() end ) print("Start debug session")
vim.keymap.set('n', '<F7>', function () require('dap').step_into() end ) require('dap').continue()
end)
vim.keymap.set('n', '<F6>', function() require('dap').step_over() end)
vim.keymap.set('n', '<F7>', function() require('dap').step_into() end)
vim.keymap.set('n', '<leader>=',":Gen Generate<CR>") vim.keymap.set('n', '<leader>=', ":Gen Generate<CR>")
-- Easily hit escape in terminal mode. -- Easily hit escape in terminal mode.
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>") vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")
@ -45,3 +53,22 @@ vim.keymap.set("n", ",st", function()
vim.wo.winfixheight = true vim.wo.winfixheight = true
vim.cmd.term() vim.cmd.term()
end) end)
-- Open quickfix list
vim.keymap.set("n", "<M-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<M-j>", "<cmd>cprev<CR>zz")
-- Go to next in location list
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
-- Highlight on yank
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking text ",
group = vim.api.nvim_create_augroup('barink', { clear = true }),
callback = function()
vim.highlight.on_yank()
end
})

View File

@ -2,13 +2,13 @@ return {
{ {
"stevearc/oil.nvim", "stevearc/oil.nvim",
opt = { opt = {
default_file_explorer = false default_file_explorer = true
}, },
dependencies = { dependencies = {
'nvim-tree/nvim-web-devicons' 'nvim-tree/nvim-web-devicons'
}, },
config = function () config = function()
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc= "Open parent directory"}) vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
end end
} }
} }

View File

@ -1,8 +1,8 @@
return { return {
{
"j-hui/fidget.nvim", "j-hui/fidget.nvim",
opt = { config = function()
} local opts = {
} }
require("fidget").setup(opts)
end
} }

View File

@ -1,4 +1,29 @@
return { return {
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
opt = {} config = function()
local opts = {
signs = {
add = { text = '+' },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "-" },
changedelete = { text = "~" }
},
signs_staged = {
add = { text = '+' },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "-" },
changedelete = { text = "~" },
untracked = { text = "*" },
},
signs_staged_enable = true,
signcolumn = true,
watch_gitdir = {
follow_files = true
},
auto_attach = true
}
require("gitsigns").setup(opts)
end,
} }

View File

@ -1,5 +1,5 @@
return return
{ {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
{ {
@ -15,14 +15,17 @@ return
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
{ {
'L3MON4D3/LuaSnip', 'L3MON4D3/LuaSnip',
dependencies = 'hrsh7th/nvim-cmp', dependencies = {
'hrsh7th/nvim-cmp',
'rafamadriz/friendly-snippets',
},
version = "v2.*", version = "v2.*",
}, },
{'mfussenegger/nvim-jdtls', dependencies = {'nvim-dap'}}, { 'mfussenegger/nvim-jdtls', dependencies = { 'nvim-dap' } },
"onsails/lspkind.nvim", "onsails/lspkind.nvim",
}, },
config = function() config = function()
vim.opt.completeopt = { "menu", "menuone", "noselect", "preview"} vim.opt.completeopt = { "menu", "menuone", "noselect", "preview" }
require("lspkind").init({}) require("lspkind").init({})
require("mason").setup() require("mason").setup()
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
@ -55,12 +58,12 @@ return
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(), ['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ['<C-y>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp', keyword_length = 1 }, { name = 'nvim_lsp', keyword_length = 1 },
{ name = 'luasnip' },
{ name = 'path' }, { name = 'path' },
}, {
{ name = 'buffer', keyword_length = 2 }, { name = 'buffer', keyword_length = 2 },
}), }),
window = { window = {
@ -78,10 +81,10 @@ return
}) })
}) })
cmp.setup.filetype({ "sql"}, { cmp.setup.filetype({ "sql" }, {
sources = { sources = {
{ name = "vim-dadbod-completion"}, { name = "vim-dadbod-completion" },
{ name = "buffer"} , { name = "buffer" },
} }
}) })
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
@ -98,29 +101,28 @@ return
}) })
vim.keymap.set({"i", "s"}, "<C-K>", function() ls.expand() end, {silent = true}) vim.keymap.set({ "i", "s" }, "<C-K>", function() ls.expand() end, { silent = true })
vim.keymap.set({"i", "s"}, "<C-n>", function() ls.jump(1) end, {silent = true }) vim.keymap.set({ "i", "s" }, "<C-n>", function() ls.jump(1) end, { silent = true })
vim.keymap.set({"i", "s"}, "<C-p>", function() ls.jump(-1) end, {silent = true}) vim.keymap.set({ "i", "s" }, "<C-p>", function() ls.jump(-1) end, { silent = true })
vim.keymap.set({"i", "s"}, "<C-E>", function() vim.keymap.set({ "i", "s" }, "<C-E>", function()
if ls.choice_active() then if ls.choice_active() then
ls.change_choice(1) ls.change_choice(1)
end end
end, {silent = true}) end, { silent = true })
require("luasnip.loaders.from_lua").load({paths= "~/.config/nvim/lua/barink/snippets"})
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/lua/barink/snippets" })
require("luasnip.loaders.from_vscode").lazy_load()
-- Set up lspconfig. -- Set up lspconfig.
local capabilities = require("cmp_nvim_lsp").default_capabilities() local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lsp = require("lspconfig") local lsp = require("lspconfig")
local language_server = { local language_server = {
asm_lsp= true, asm_lsp = true,
mojo = true, mojo = true,
zls = true, zls = true,
emmet_language_server = true, emmet_language_server = true,
rust_analyzer = true, rust_analyzer = true,
gdtoolkit = { flags = { debounce_text_changes = 150 }}, --gdtoolkit = { flags = { debounce_text_changes = 150 }},
jdtls = true, jdtls = true,
pylsp = true, pylsp = true,
phpactor = { phpactor = {
@ -132,8 +134,8 @@ return
clangd = { clangd = {
capabilities = capabilities, capabilities = capabilities,
root_dir = require('lspconfig').util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"), root_dir = require('lspconfig').util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"),
cmd = {"clangd"}, cmd = { "clangd" },
filetypes = { "c", "cpp", "objc", "objcpp"}, filetypes = { "c", "cpp", "objc", "objcpp" },
settings = { settings = {
clangd = { clangd = {
compilationDatabasePath = "compile-commands.json", compilationDatabasePath = "compile-commands.json",
@ -151,14 +153,14 @@ return
version = 'LuaJIT', version = 'LuaJIT',
}, },
workspace = { workspace = {
checkThirdParty= false, checkThirdParty = false,
library = { library = {
vim.env.VIMRUNTIME vim.env.VIMRUNTIME
} }
}, },
-- diagnostics = { diagnostics = {
-- globals = { 'vim'} globals = { 'vim' }
-- } }
} }
} }
} }
@ -173,7 +175,7 @@ return
lsp[name].setup({}) lsp[name].setup({})
end end
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
callback = function (args) callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id), "must have valid client") local client = assert(vim.lsp.get_client_by_id(args.data.client_id), "must have valid client")
local settings = language_server[client.name] local settings = language_server[client.name]
@ -184,17 +186,15 @@ return
local builtin = require "telescope.builtin" local builtin = require "telescope.builtin"
vim.opt_local.omnifunc = "v:lua.vim.lsp.omnifunc" vim.opt_local.omnifunc = "v:lua.vim.lsp.omnifunc"
vim.keymap.set("n", "gd", builtin.lsp_definitions, {buffer = -1}) vim.keymap.set("n", "gd", builtin.lsp_definitions, { buffer = -1 })
vim.keymap.set("n", "gr", builtin.lsp_references, {buffer = -1}) vim.keymap.set("n", "gr", builtin.lsp_references, { buffer = -1 })
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, {buffer = -1}) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = -1 })
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, {buffer = -1}) vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, { buffer = -1 })
vim.keymap.set("n", "K", vim.lsp.buf.hover, {buffer = -1}) vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = -1 })
vim.keymap.set("n", "<LEADER>cr", vim.lsp.buf.rename, {buffer =-1})
vim.keymap.set("n", "<LEADER>ca", vim.lsp.buf.code_action, {buffer = -1})
vim.keymap.set("n", "<LEADER>wd", builtin.lsp_document_symbols, {buffer = -1})
vim.keymap.set("n", "<LEADER>cr", vim.lsp.buf.rename, { buffer = -1 })
vim.keymap.set("n", "<LEADER>ca", vim.lsp.buf.code_action, { buffer = -1 })
vim.keymap.set("n", "<LEADER>wd", builtin.lsp_document_symbols, { buffer = -1 })
end end
}) })
end, end,

View File

@ -1,15 +0,0 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
},
keys = {
{
"<leader>?",
function()
require("which-key").show({global = false})
end,
desc = "Buffer Local Keymaps (which-key)",
}
}
}

View File

@ -21,20 +21,21 @@ vim.opt.termguicolors = true
vim.opt.scrolloff = 8 vim.opt.scrolloff = 8
vim.g.netrw_browse_split = 0 vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
vim.g.netrw_winsize = 25
vim.opt.completeopt = {'menu', 'menuone', 'noselect' }
vim.opt.inccommand = 'split' vim.opt.inccommand = 'split'
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
callback = function (args) callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id) local client = vim.lsp.get_client_by_id(args.data.client_id)
if client.server_capabilities.hoverProvider then if client.server_capabilities.hoverProvider then
vim.keymap.set('n', 'K', vim.lsp.buf.hover, {buffer = args.buf}) vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = args.buf })
end end
end, end,
}) })
vim.g.netrw_browse_split = 0
vim.g.netrw_winsize = 25
--[[ --[[
-- Run zig test on save -- Run zig test on save
-- TODO: fix vim.cmd call -- TODO: fix vim.cmd call
@ -43,7 +44,4 @@ vim.api.nvim_create_autocmd('BufWritePost' , {
callback = function () callback = function ()
vim.cmd{cmd = '!zig' , args= {'test', vim.fn.expand('%')} } vim.cmd{cmd = '!zig' , args= {'test', vim.fn.expand('%')} }
end end
})]]-- })]] --