mirror of
https://github.com/mikkelsvartveit/dotfiles.git
synced 2025-12-22 11:12:39 +00:00
Run formatter on plugins.lua
This commit is contained in:
parent
a8057cb6a9
commit
261ae0f781
1 changed files with 293 additions and 290 deletions
|
|
@ -1,321 +1,324 @@
|
||||||
-- Install lazy.nvim (plugin manager)
|
-- Install lazy.nvim (plugin manager)
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
"git",
|
"git",
|
||||||
"clone",
|
"clone",
|
||||||
"--filter=blob:none",
|
"--filter=blob:none",
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
"--branch=stable", -- latest stable release
|
"--branch=stable", -- latest stable release
|
||||||
lazypath,
|
lazypath,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
-- Install plugins
|
-- Install plugins
|
||||||
require("lazy").setup({
|
require("lazy").setup({
|
||||||
-- Color scheme
|
-- Color scheme
|
||||||
{
|
{
|
||||||
"catppuccin/nvim",
|
"catppuccin/nvim",
|
||||||
name = "catppuccin",
|
name = "catppuccin",
|
||||||
priority = 1000,
|
priority = 1000,
|
||||||
config = function(plugin)
|
config = function(plugin)
|
||||||
vim.cmd.colorscheme "catppuccin-macchiato"
|
vim.cmd.colorscheme("catppuccin-macchiato")
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Treesitter config
|
-- Treesitter config
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
branch = 'master',
|
branch = "master",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
build = ":TSUpdate",
|
build = ":TSUpdate",
|
||||||
config = function()
|
config = function()
|
||||||
require("nvim-treesitter.configs").setup {
|
require("nvim-treesitter.configs").setup({
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true,
|
enable = true,
|
||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- LSP config
|
-- LSP config
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Mason for easy LSP installation
|
-- Mason for easy LSP installation
|
||||||
{ "mason-org/mason.nvim", opts = {} },
|
{ "mason-org/mason.nvim", opts = {} },
|
||||||
{ "mason-org/mason-lspconfig.nvim", opts = {
|
{
|
||||||
handlers = {
|
"mason-org/mason-lspconfig.nvim",
|
||||||
-- Make it play with nvim-cmp
|
opts = {
|
||||||
function(server_name)
|
handlers = {
|
||||||
require("lspconfig")[server_name].setup({
|
-- Make it play with nvim-cmp
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities()
|
function(server_name)
|
||||||
})
|
require("lspconfig")[server_name].setup({
|
||||||
end,
|
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||||
},
|
})
|
||||||
} },
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
-- Autocompletion (nvim-cmp)
|
-- Autocompletion (nvim-cmp)
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
"hrsh7th/cmp-nvim-lsp", -- LSP source for nvim-cmp
|
"hrsh7th/cmp-nvim-lsp", -- LSP source for nvim-cmp
|
||||||
"L3MON4D3/LuaSnip", -- Snippet engine
|
"L3MON4D3/LuaSnip", -- Snippet engine
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
-- Setup nvim-cmp
|
-- Setup nvim-cmp
|
||||||
local cmp = require('cmp')
|
local cmp = require("cmp")
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
sources = {
|
sources = {
|
||||||
{name = 'nvim_lsp'},
|
{ name = "nvim_lsp" },
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
-- Enter key confirms completion item
|
-- Enter key confirms completion item
|
||||||
['<CR>'] = cmp.mapping.confirm({select = true}),
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
|
||||||
-- Ctrl + space triggers completion menu
|
-- Ctrl + space triggers completion menu
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
}),
|
}),
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
require('luasnip').lsp_expand(args.body)
|
require("luasnip").lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Keymaps
|
-- Keymaps
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
callback = function(event)
|
callback = function(event)
|
||||||
local opts = {buffer = event.buf}
|
local opts = { buffer = event.buf }
|
||||||
|
|
||||||
vim.keymap.set("n", "gd", '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
|
vim.keymap.set("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>", opts)
|
||||||
vim.keymap.set("n", "gh", '<cmd>lua vim.diagnostic.open_float()<cr>', opts)
|
vim.keymap.set("n", "gh", "<cmd>lua vim.diagnostic.open_float()<cr>", opts)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Formatting with null-ls
|
-- Formatting with null-ls
|
||||||
{
|
{
|
||||||
"nvimtools/none-ls.nvim",
|
"nvimtools/none-ls.nvim",
|
||||||
dependencies = { "nvim-lua/plenary.nvim" },
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
config = function()
|
config = function()
|
||||||
local null_ls = require("null-ls")
|
local null_ls = require("null-ls")
|
||||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
null_ls.setup({
|
null_ls.setup({
|
||||||
sources = {
|
sources = {
|
||||||
null_ls.builtins.formatting.prettierd,
|
null_ls.builtins.formatting.prettierd,
|
||||||
null_ls.builtins.formatting.black,
|
null_ls.builtins.formatting.black,
|
||||||
null_ls.builtins.formatting.stylua,
|
null_ls.builtins.formatting.stylua,
|
||||||
},
|
},
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
if client.supports_method("textDocument/formatting") then
|
if client.supports_method("textDocument/formatting") then
|
||||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
group = augroup,
|
group = augroup,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.lsp.buf.format({
|
vim.lsp.buf.format({
|
||||||
async = false,
|
async = false,
|
||||||
filter = function(client)
|
filter = function(client)
|
||||||
return client.name == "null-ls"
|
return client.name == "null-ls"
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Easy commenting/uncommenting
|
-- Easy commenting/uncommenting
|
||||||
{
|
{
|
||||||
"numToStr/Comment.nvim",
|
"numToStr/Comment.nvim",
|
||||||
config = true,
|
config = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Easy handling of surroundings
|
-- Easy handling of surroundings
|
||||||
{
|
{
|
||||||
"tpope/vim-surround",
|
"tpope/vim-surround",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"tpope/vim-repeat",
|
"tpope/vim-repeat",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Auto-match brackets, quotes etc.
|
-- Auto-match brackets, quotes etc.
|
||||||
{
|
{
|
||||||
'windwp/nvim-autopairs',
|
"windwp/nvim-autopairs",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
opts = {},
|
opts = {},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Supermaven AI assist
|
-- Supermaven AI assist
|
||||||
{
|
{
|
||||||
"supermaven-inc/supermaven-nvim",
|
"supermaven-inc/supermaven-nvim",
|
||||||
config = function()
|
config = function()
|
||||||
vim.api.nvim_create_user_command("CPE", "SupermavenStart", {})
|
vim.api.nvim_create_user_command("CPE", "SupermavenStart", {})
|
||||||
vim.api.nvim_create_user_command("CPD", "SupermavenStop", {})
|
vim.api.nvim_create_user_command("CPD", "SupermavenStop", {})
|
||||||
|
|
||||||
require("supermaven-nvim").setup({})
|
require("supermaven-nvim").setup({})
|
||||||
|
|
||||||
-- Disable on startup
|
-- Disable on startup
|
||||||
vim.api.nvim_command("silent! SupermavenStop")
|
vim.api.nvim_command("silent! SupermavenStop")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Auto-restore session when opening Neovim
|
-- Auto-restore session when opening Neovim
|
||||||
{
|
{
|
||||||
"rmagatti/auto-session",
|
"rmagatti/auto-session",
|
||||||
opts = {
|
opts = {
|
||||||
log_level = "error",
|
log_level = "error",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- File explorer sidebar
|
-- File explorer sidebar
|
||||||
{
|
{
|
||||||
"kyazdani42/nvim-tree.lua",
|
"kyazdani42/nvim-tree.lua",
|
||||||
commit = "e14989c", -- newer versions break auto-session
|
commit = "e14989c", -- newer versions break auto-session
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"kyazdani42/nvim-web-devicons",
|
"kyazdani42/nvim-web-devicons",
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
actions = {
|
actions = {
|
||||||
open_file = {
|
open_file = {
|
||||||
quit_on_open = true,
|
quit_on_open = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
update_focused_file = {
|
update_focused_file = {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
view = {
|
view = {
|
||||||
signcolumn = "auto",
|
signcolumn = "auto",
|
||||||
adaptive_size = true,
|
adaptive_size = true,
|
||||||
mappings = {
|
mappings = {
|
||||||
list = {
|
list = {
|
||||||
{ key = "+", action = "cd" },
|
{ key = "+", action = "cd" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
init = function()
|
init = function()
|
||||||
vim.g.loaded_netrw = 1
|
vim.g.loaded_netrw = 1
|
||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
vim.keymap.set("n", "<leader>n", ":NvimTreeToggle<CR>", { noremap = true, silent = true })
|
vim.keymap.set("n", "<leader>n", ":NvimTreeToggle<CR>", { noremap = true, silent = true })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Fuzzy finder for files, buffers, etc.
|
-- Fuzzy finder for files, buffers, etc.
|
||||||
{
|
{
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
tag = "0.1.4",
|
tag = "0.1.4",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
{"nvim-telescope/telescope-fzf-native.nvim", build = "make"},
|
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{"<leader>p", "<cmd>Telescope find_files<CR>", noremap = true, silent = true},
|
{ "<leader>p", "<cmd>Telescope find_files<CR>", noremap = true, silent = true },
|
||||||
{"<leader>f", "<cmd>Telescope live_grep<CR>", noremap = true, silent = true},
|
{ "<leader>f", "<cmd>Telescope live_grep<CR>", noremap = true, silent = true },
|
||||||
{"<leader>b", "<cmd>Telescope buffers<CR>", noremap = true, silent = true},
|
{ "<leader>b", "<cmd>Telescope buffers<CR>", noremap = true, silent = true },
|
||||||
{"<leader>o", "<cmd>Telescope oldfiles<CR>", noremap = true, silent = true},
|
{ "<leader>o", "<cmd>Telescope oldfiles<CR>", noremap = true, silent = true },
|
||||||
{"<leader>t", "<cmd>Telescope lsp_workspace_symbols<CR>", noremap = true, silent = true},
|
{ "<leader>t", "<cmd>Telescope lsp_workspace_symbols<CR>", noremap = true, silent = true },
|
||||||
{"<leader>c", "<cmd>Telescope commands<CR>", noremap = true, silent = true},
|
{ "<leader>c", "<cmd>Telescope commands<CR>", noremap = true, silent = true },
|
||||||
{"<leader>:", "<cmd>Telescope commands<CR>", noremap = true, silent = true},
|
{ "<leader>:", "<cmd>Telescope commands<CR>", noremap = true, silent = true },
|
||||||
{"<leader>d", "<cmd>Telescope git_status<CR>", noremap = true, silent = true},
|
{ "<leader>d", "<cmd>Telescope git_status<CR>", noremap = true, silent = true },
|
||||||
{"<leader><leader>", "<cmd>Telescope resume<CR>", noremap = true, silent = true},
|
{ "<leader><leader>", "<cmd>Telescope resume<CR>", noremap = true, silent = true },
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("telescope").setup({
|
require("telescope").setup({
|
||||||
defaults = {
|
defaults = {
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
["<esc>"] = require("telescope.actions").close, -- Disable normal mode
|
["<esc>"] = require("telescope.actions").close, -- Disable normal mode
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
vimgrep_arguments = {
|
vimgrep_arguments = {
|
||||||
"rg",
|
"rg",
|
||||||
"--color=never",
|
"--color=never",
|
||||||
"--no-heading",
|
"--no-heading",
|
||||||
"--with-filename",
|
"--with-filename",
|
||||||
"--line-number",
|
"--line-number",
|
||||||
"--column",
|
"--column",
|
||||||
"--smart-case",
|
"--smart-case",
|
||||||
"--fixed-strings",
|
"--fixed-strings",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
require("telescope").load_extension("fzf")
|
require("telescope").load_extension("fzf")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Persistent terminal that can be toggled with a keybinding
|
-- Persistent terminal that can be toggled with a keybinding
|
||||||
{
|
{
|
||||||
"akinsho/nvim-toggleterm.lua",
|
"akinsho/nvim-toggleterm.lua",
|
||||||
tag = "2.4.0",
|
tag = "2.4.0",
|
||||||
keys = "<C-j>",
|
keys = "<C-j>",
|
||||||
config = function()
|
config = function()
|
||||||
require("toggleterm").setup({
|
require("toggleterm").setup({
|
||||||
hide_numbers = true,
|
hide_numbers = true,
|
||||||
direction = 'float',
|
direction = "float",
|
||||||
open_mapping = [[<C-j>]],
|
open_mapping = [[<C-j>]],
|
||||||
shell = 'fish',
|
shell = "fish",
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Run code with a keybinding
|
-- Run code with a keybinding
|
||||||
{
|
{
|
||||||
"CRAG666/code_runner.nvim",
|
"CRAG666/code_runner.nvim",
|
||||||
cmd = "RunCode",
|
cmd = "RunCode",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"akinsho/nvim-toggleterm.lua"
|
"akinsho/nvim-toggleterm.lua",
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
mode = "toggleterm",
|
mode = "toggleterm",
|
||||||
filetype = {
|
filetype = {
|
||||||
python = "python3",
|
python = "python3",
|
||||||
javascript = "node",
|
javascript = "node",
|
||||||
typescript = "ts-node --esm",
|
typescript = "ts-node --esm",
|
||||||
c = "gcc -o main % && ./main",
|
c = "gcc -o main % && ./main",
|
||||||
go = "go run",
|
go = "go run",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
init = function()
|
init = function()
|
||||||
vim.keymap.set("n", "<leader><CR>", ":RunCode<CR>", { noremap = true })
|
vim.keymap.set("n", "<leader><CR>", ":RunCode<CR>", { noremap = true })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Live Markdown preview in browser
|
-- Live Markdown preview in browser
|
||||||
-- {
|
-- {
|
||||||
-- "iamcco/markdown-preview.nvim",
|
-- "iamcco/markdown-preview.nvim",
|
||||||
-- build = "cd app && npm install",
|
-- build = "cd app && npm install",
|
||||||
-- ft = "markdown",
|
-- ft = "markdown",
|
||||||
-- init = function()
|
-- init = function()
|
||||||
-- vim.g.mkdp_auto_close = 0
|
-- vim.g.mkdp_auto_close = 0
|
||||||
-- end,
|
-- end,
|
||||||
-- },
|
-- },
|
||||||
|
|
||||||
-- Git integration - show modified lines next to line numbers
|
-- Git integration - show modified lines next to line numbers
|
||||||
{
|
{
|
||||||
"lewis6991/gitsigns.nvim",
|
"lewis6991/gitsigns.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("gitsigns").setup()
|
require("gitsigns").setup()
|
||||||
require("scrollbar.handlers.gitsigns").setup()
|
require("scrollbar.handlers.gitsigns").setup()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- VSCode-like scrollbar with Git and diagnostic markers
|
-- VSCode-like scrollbar with Git and diagnostic markers
|
||||||
{
|
{
|
||||||
"petertriho/nvim-scrollbar",
|
"petertriho/nvim-scrollbar",
|
||||||
config = true,
|
config = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Smooth scrolling
|
-- Smooth scrolling
|
||||||
{
|
{
|
||||||
"karb94/neoscroll.nvim",
|
"karb94/neoscroll.nvim",
|
||||||
opts = {
|
opts = {
|
||||||
easing_function = "sine",
|
easing_function = "sine",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue