Basic setup

This commit is contained in:
Karolis Arbaciauskas 2024-11-03 00:27:08 +02:00
parent 2ba39c6973
commit 0185a988a2
No known key found for this signature in database
15 changed files with 412 additions and 38 deletions

116
init.lua
View File

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true
-- [[ Setting options ]]
-- See `:help vim.opt`
@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
vim.opt.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true
vim.opt.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a'
@ -243,18 +243,18 @@ require('lazy').setup({
-- require('gitsigns').setup({ ... })
--
-- See `:help gitsigns` to understand what the configuration keys do
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
},
},
-- { -- Adds git related signs to the gutter, as well as utilities for managing changes
-- 'lewis6991/gitsigns.nvim',
-- opts = {
-- signs = {
-- add = { text = '+' },
-- change = { text = '~' },
-- delete = { text = '_' },
-- topdelete = { text = '‾' },
-- changedelete = { text = '~' },
-- },
-- },
-- },
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
--
@ -615,7 +615,40 @@ require('lazy').setup({
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
-- clangd = {},
-- gopls = {},
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 = true,
-- compositeLiteralFields = true,
-- compositeLiteralTypes = true,
-- constantValues = true,
-- functionTypeParameters = true,
-- parameterNames = true,
-- rangeVariableTypes = true,
-- },
-- analyses = {
-- fieldalignment = true,
-- nilness = true,
-- unusedparams = true,
-- unusedwrite = true,
-- useany = true,
-- },
-- usePlaceholders = true,
-- completeUnimported = true,
-- staticcheck = true,
-- directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' },
-- semanticTokens = true,
},
-- pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
@ -656,6 +689,12 @@ require('lazy').setup({
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
'prettierd',
'goimports',
'gofumpt',
'gomodifytags',
'impl',
'delve',
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
@ -708,6 +747,8 @@ require('lazy').setup({
end,
formatters_by_ft = {
lua = { 'stylua' },
yaml = { 'prettierd' },
go = { 'goimports', 'gofumpt' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
@ -737,12 +778,12 @@ require('lazy').setup({
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets
-- {
-- 'rafamadriz/friendly-snippets',
-- config = function()
-- require('luasnip.loaders.from_vscode').lazy_load()
-- end,
-- },
{
'rafamadriz/friendly-snippets',
config = function()
require('luasnip.loaders.from_vscode').lazy_load()
end,
},
},
},
'saadparwaiz1/cmp_luasnip',
@ -825,6 +866,7 @@ require('lazy').setup({
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = 'copilot' },
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
@ -838,13 +880,14 @@ require('lazy').setup({
-- change the command in the config to whatever the name of that colorscheme is.
--
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
'folke/tokyonight.nvim',
'catppuccin/nvim',
name = 'catppuccin',
priority = 1000, -- Make sure to load this before all the other start plugins.
init = function()
-- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'tokyonight-night'
vim.cmd.colorscheme 'catppuccin-mocha'
-- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none'
@ -897,7 +940,24 @@ require('lazy').setup({
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
ensure_installed = {
'bash',
'c',
'diff',
'go',
'gomod',
'gowork',
'gosum',
'html',
'lua',
'luadoc',
'markdown',
'markdown_inline',
'query',
'yaml',
'vim',
'vimdoc',
},
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
@ -926,12 +986,12 @@ require('lazy').setup({
-- Here are some example plugins that I've included in the Kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
require 'kickstart.plugins.debug',
require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.

View File

@ -0,0 +1,31 @@
return {
{
'goolord/alpha-nvim',
event = 'VimEnter',
enabled = true,
init = false,
dependencies = {
'echasnovski/mini.icons',
'nvim-lua/plenary.nvim',
},
config = function()
local alpha = require 'alpha'
local dashboard = require 'alpha.themes.dashboard'
dashboard.section.buttons.val = {
dashboard.button('e', ' New file', '<cmd>ene <CR>'),
dashboard.button('f', '󰈞 Find file', '<cmd>Telescope find_files<cr>'),
dashboard.button('h', '󰊄 Recently opened files', '<cmd>Telescope oldfiles<cr>'),
-- dashboard.button('SPC f r', ' Frecency/MRU'),
dashboard.button('g', '󰈬 Find word', '<cmd>Telescope live_grep<cr>'),
-- dashboard.button('<leader> fm', ' Jump to bookmarks'),
dashboard.button('s', ' Open last session', '<cmd> lua require("persistence").load() <cr>'),
dashboard.button('sl', ' Select Session', '<cmd> lua require("persistence").select() <cr>'),
dashboard.button('u', ' Update plugins', '<cmd>Lazy sync<CR>'),
dashboard.button('c', ' Configuration', "<cmd>lua require('telescope.builtin').find_files { cwd = vim.fn.stdpath 'config' } <cr>"),
dashboard.button('q', '󰅚 Quit', '<cmd>qa<CR>'),
}
alpha.setup(dashboard.config)
end,
},
}

View File

@ -0,0 +1,52 @@
local on_attach = function(on_attach, name)
return vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local buffer = args.buf ---@type number
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client and (not name or client.name == name) then
return on_attach(client, buffer)
end
end,
})
end
return {
{
'zbirenbaum/copilot.lua',
cmd = 'Copilot',
-- new
-- event = 'InsertEnter',
build = ':Copilot auth',
opts = {
suggestion = { enabled = false },
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
},
},
},
{
'zbirenbaum/copilot-cmp',
dependencies = 'copilot.lua',
opts = {},
config = function(_, opts)
local copilot_cmp = require 'copilot_cmp'
copilot_cmp.setup(opts)
on_attach(function(client)
copilot_cmp._on_insert_enter {}
end, 'copilot')
end,
},
{
'olimorris/codecompanion.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-treesitter/nvim-treesitter',
'hrsh7th/nvim-cmp', -- Optional: For using slash commands and variables in the chat buffer
'nvim-telescope/telescope.nvim', -- Optional: For using slash commands
{ 'stevearc/dressing.nvim', opts = {} }, -- Optional: Improves `vim.ui.select`
},
config = true,
},
}

View File

@ -0,0 +1,51 @@
return {
{
'CopilotC-Nvim/CopilotChat.nvim',
branch = 'canary',
dependencies = {
{ 'zbirenbaum/copilot.lua' }, -- or github/copilot.vim
{ 'nvim-lua/plenary.nvim' }, -- for curl, log wrapper
},
build = 'make tiktoken', -- Only on MacOS or Linux
opts = {
debug = true, -- Enable debugging
context = 'buffer',
},
keys = {
{
'<leader>aa',
function()
local chat = require 'CopilotChat'
chat.toggle()
end,
desc = 'Copilot toggle chat',
},
{
'<leader>aq',
function()
local input = vim.fn.input 'Quick Chat: '
if input ~= '' then
require('CopilotChat').ask(input, { selection = require('CopilotChat.select').buffer })
end
end,
desc = 'Copilot quick chat',
},
{
'<leader>ax',
function()
local chat = require 'CopilotChat'
chat.reset()
end,
desc = 'Copilot chat reset',
},
{
'<leader>ap',
function()
local actions = require 'CopilotChat.actions'
require('CopilotChat.integrations.telescope').pick(actions.prompt_actions())
end,
desc = 'Copilot chat prompt actions',
},
},
},
}

64
lua/custom/plugins/go.lua Normal file
View File

@ -0,0 +1,64 @@
local on_attach = function(client, bufnr)
if not client.server_capabilities.semanticTokensProvider then
local semantic = client.config.capabilities.textDocument.semanticTokens
client.server_capabilities.semanticTokensProvider = {
full = true,
legend = {
tokenTypes = semantic.tokenTypes,
tokenModifiers = semantic.tokenModifiers,
},
range = true,
}
end
end
require('lspconfig').gopls.setup {
on_attach = on_attach,
}
return {
{
'leoluz/nvim-dap-go',
opts = {},
},
{
'fredrikaverpil/neotest-golang',
},
{
'echasnovski/mini.icons',
opts = {
file = {
['.go-version'] = { glyph = '', hl = 'MiniIconsBlue' },
},
filetype = {
gotmpl = { glyph = '󰟓', hl = 'MiniIconsGrey' },
},
},
},
{
'mfussenegger/nvim-dap',
optional = true,
dependencies = {
{
'leoluz/nvim-dap-go',
opts = {},
},
},
},
{
'nvim-neotest/neotest',
optional = true,
dependencies = {
'fredrikaverpil/neotest-golang',
},
opts = {
adapters = {
['neotest-golang'] = {
-- Here we can set options for neotest-golang, e.g.
-- go_test_args = { "-v", "-race", "-count=1", "-timeout=60s" },
dap_go_enabled = true, -- requires leoluz/nvim-dap-go
},
},
},
},
}

View File

@ -0,0 +1,22 @@
return {
'MagicDuck/grug-far.nvim',
opts = { headerMaxWidth = 80 },
cmd = 'GrugFar',
keys = {
{
'<leader>sR',
function()
local grug = require 'grug-far'
local ext = vim.bo.buftype == '' and vim.fn.expand '%:e'
grug.open {
transient = true,
prefills = {
filesFilter = ext and ext ~= '' and '*.' .. ext or nil,
},
}
end,
mode = { 'n', 'v' },
desc = 'Search and Replace',
},
},
}

View File

@ -2,4 +2,11 @@
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
vim.api.nvim_create_autocmd({ 'FocusGained', 'BufEnter' }, { command = 'checktime' })
vim.keymap.set('n', '<A-h>', '<C-w>5<', { desc = 'Decrease window width' })
vim.keymap.set('n', '<A-l>', '<C-w>5>', { desc = 'Increase window width' })
vim.keymap.set('n', '<A-j>', '<C-w>1+', { desc = 'Increase window height' })
vim.keymap.set('n', '<A-k>', '<C-w>1-', { desc = 'Decrease window height' })
return {}

View File

@ -0,0 +1,21 @@
return {
'kdheepak/lazygit.nvim',
lazy = true,
cmd = {
'LazyGit',
'LazyGitConfig',
'LazyGitCurrentFile',
'LazyGitFilter',
'LazyGitFilterCurrentFile',
},
dependencies = {
'nvim-lua/plenary.nvim',
},
keys = {
{ '<leader>gg', '<cmd>LazyGit<cr>', desc = 'Lazygit (Root Dir)' },
{ '<leader>gf', '<cmd>LazyGitFilterCurrentFile<cr>', desc = 'Lazygit Current File History' },
{ '<leader>gl', '<cmd>LazyGitFilter<cr>', desc = 'Lazygit log' },
{ '<leader>gb', '<cmd>Gitsigns blame<cr>', desc = 'Git blame' },
{ '<leader>gs', '<cmd>Telescope git_status<CR>', desc = 'Git Status' },
},
}

View File

@ -0,0 +1,5 @@
return {
'chentoast/marks.nvim',
event = 'VeryLazy',
opts = {},
}

View File

@ -0,0 +1,22 @@
return {
'stevearc/oil.nvim',
---@module 'oil'
---@type oil.SetupOpts
opts = {},
dependencies = {
{ 'echasnovski/mini.icons', opts = {} },
{ 'nvim-tree/nvim-web-devicons', opts = {} },
},
config = function()
require('oil').setup {
keymaps = {
['<Esc>'] = 'actions.close',
['<C-h>'] = false,
},
}
end,
keys = {
-- { '=', '<cmd>Oil<cr>', mode = 'n', desc = 'Open Filesystem' },
{ '-', '<cmd>Oil --float<cr>', mode = 'n', desc = 'Open Floating Filesystem' },
},
}

View File

@ -0,0 +1,7 @@
return {
{
'folke/persistence.nvim',
event = 'BufReadPre',
opts = {},
},
}

View File

@ -0,0 +1,17 @@
return {
'christoomey/vim-tmux-navigator',
cmd = {
'TmuxNavigateLeft',
'TmuxNavigateDown',
'TmuxNavigateUp',
'TmuxNavigateRight',
'TmuxNavigatePrevious',
},
keys = {
{ '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>' },
{ '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>' },
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>' },
{ '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>' },
{ '<c-\\>', '<cmd><C-U>TmuxNavigatePrevious<cr>' },
},
}

View File

@ -0,0 +1,14 @@
return {
'vim-test/vim-test',
dependencies = {
'preservim/vimux',
},
setup = {
vim.cmd 'let test#strategy = "vimux"',
},
keys = {
{ '<leader>tt', '<cmd>TestFile<CR>', { desc = 'Test file' } },
{ '<leader>tn', '<cmd>TestNearest<CR>', { desc = 'Test nearest' } },
{ '<leader>tl', '<cmd>TestLast<CR>', { desc = 'Test last' } },
},
}

View File

@ -90,16 +90,16 @@ return {
}
-- Change breakpoint icons
-- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' })
-- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' })
-- local breakpoint_icons = vim.g.have_nerd_font
-- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
-- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' }
-- for type, icon in pairs(breakpoint_icons) do
-- local tp = 'Dap' .. type
-- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak'
-- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl })
-- end
vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' })
vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' })
local breakpoint_icons = vim.g.have_nerd_font
and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
or { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
for type, icon in pairs(breakpoint_icons) do
local tp = 'Dap' .. type
local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak'
vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl })
end
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close

View File

@ -6,6 +6,7 @@ return {
{
'lewis6991/gitsigns.nvim',
opts = {
current_line_blame = true,
on_attach = function(bufnr)
local gitsigns = require 'gitsigns'