Add support for more formatter's, stylua config.

This commit is contained in:
CronyAkatsuki 2023-12-24 19:46:29 +01:00
parent 24f7bb50b6
commit ccc9ffa2db
19 changed files with 472 additions and 420 deletions

View File

@ -1,11 +1,11 @@
require("nvim-autopairs").setup {}
require("nvim-autopairs").setup({})
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
local handlers = require('nvim-autopairs.completion.handlers')
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp")
local handlers = require("nvim-autopairs.completion.handlers")
cmp.event:on(
'confirm_done',
"confirm_done",
cmp_autopairs.on_confirm_done({
filetypes = {
-- "*" is a alias to all filetypes
@ -15,14 +15,14 @@ cmp.event:on(
cmp.lsp.CompletionItemKind.Function,
cmp.lsp.CompletionItemKind.Method,
},
handler = handlers["*"]
}
handler = handlers["*"],
},
},
lua = {
["("] = {
kind = {
cmp.lsp.CompletionItemKind.Function,
cmp.lsp.CompletionItemKind.Method
cmp.lsp.CompletionItemKind.Method,
},
---@param char string
---@param item table item completion
@ -31,14 +31,14 @@ cmp.event:on(
---@param commit_character table<string>
handler = function(char, item, bufnr, rules, commit_character)
-- Your handler function. Inpect with print(vim.inspect{char, item, bufnr, rules, commit_character})
end
}
end,
},
},
-- Disable for tex
tex = false,
sh = false,
bash = false,
zsh = false,
}
},
})
)

View File

@ -24,7 +24,7 @@ require("catppuccin").setup({
markdown = true,
mason = true,
mini = {
enabled = true
enabled = true,
},
dap = {
enabled = true,
@ -54,4 +54,4 @@ require("catppuccin").setup({
},
})
vim.cmd.colorscheme 'catppuccin'
vim.cmd.colorscheme("catppuccin")

14
after/plugin/conform.lua Normal file
View File

@ -0,0 +1,14 @@
local conform = require("conform")
conform.setup({
formatters_by_ft = {
python = { "isort", "black" },
lua = { "stylua" },
},
})
vim.keymap.set({ "n", "v" }, "<leader>f", function()
conform.format({
lsp_fallback = true,
})
end, { desc = "Format file or range (in visual mode)" })

View File

@ -14,14 +14,14 @@ autocmd("BufWinEnter", {
local bufnr = vim.api.nvim_get_current_buf()
local opts = { buffer = bufnr, remap = false }
vim.keymap.set("n", "<leader>p", function()
vim.cmd.Git('push')
vim.cmd.Git("push")
end, opts)
-- rebase always
vim.keymap.set("n", "<leader>P", function()
vim.cmd.Git({'pull', '--rebase'})
vim.cmd.Git({ "pull", "--rebase" })
end, opts)
vim.keymap.set("n", "<leader>t", ":Git push -u origin ", opts);
vim.keymap.set("n", "<leader>t", ":Git push -u origin ", opts)
end,
})

View File

@ -4,14 +4,30 @@ local harpoon = require("harpoon")
harpoon:setup()
-- REQUIRED
vim.keymap.set("n", "<leader>a", function() harpoon:list():append() end, {desc = "Append file to harpoon starred list"})
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, {desc = "Check the list of files in harpoon"})
vim.keymap.set("n", "<leader>a", function()
harpoon:list():append()
end, { desc = "Append file to harpoon starred list" })
vim.keymap.set("n", "<C-e>", function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end, { desc = "Check the list of files in harpoon" })
vim.keymap.set("n", "<C-j>", function() harpoon:list():select(1) end, {desc = "Harpoon to 1st file in list"})
vim.keymap.set("n", "<C-k>", function() harpoon:list():select(2) end, {desc = "Harpoon to 2nd file in list"})
vim.keymap.set("n", "<C-l>", function() harpoon:list():select(3) end, {desc = "Harpoon to 3rd file in list"})
vim.keymap.set("n", "<C-;>", function() harpoon:list():select(4) end, {desc = "Harpoon to 4th file in list"})
vim.keymap.set("n", "<C-j>", function()
harpoon:list():select(1)
end, { desc = "Harpoon to 1st file in list" })
vim.keymap.set("n", "<C-k>", function()
harpoon:list():select(2)
end, { desc = "Harpoon to 2nd file in list" })
vim.keymap.set("n", "<C-l>", function()
harpoon:list():select(3)
end, { desc = "Harpoon to 3rd file in list" })
vim.keymap.set("n", "<C-;>", function()
harpoon:list():select(4)
end, { desc = "Harpoon to 4th file in list" })
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<C-S-J>", function() harpoon:list():prev() end, {desc = "Harpoon to previous file in list"})
vim.keymap.set("n", "<C-S-K>", function() harpoon:list():next() end, {desc = "Harpoon to next file in list"})
vim.keymap.set("n", "<C-S-J>", function()
harpoon:list():prev()
end, { desc = "Harpoon to previous file in list" })
vim.keymap.set("n", "<C-S-K>", function()
harpoon:list():next()
end, { desc = "Harpoon to next file in list" })

View File

@ -1,7 +1,7 @@
local lsp = require("lsp-zero")
lsp.extend_cmp()
local cmp = require('cmp')
local cmp = require("cmp")
cmp.setup({
window = {
@ -9,27 +9,27 @@ cmp.setup({
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-k>'] = cmp.mapping.select_prev_item(),
['<C-j>'] = cmp.mapping.select_next_item(),
['<C-l>'] = cmp.mapping.confirm({ select = true }),
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-l>"] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
['<Tab>'] = nil,
['<S-Tab>'] = nil,
["<Tab>"] = nil,
["<S-Tab>"] = nil,
}),
sources = {
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'nvim_lua' },
{ name = 'luasnip' },
}
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "path" },
{ name = "nvim_lua" },
{ name = "luasnip" },
},
})
lsp.set_sign_icons({
error = 'E',
warn = 'W',
hint = 'H',
info = 'I'
error = "E",
warn = "W",
hint = "H",
info = "I",
})
lsp.extend_lspconfig()
@ -37,26 +37,46 @@ lsp.extend_lspconfig()
lsp.on_attach(function(client, bufnr)
local opts = { buffer = bufnr, remap = false }
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
vim.keymap.set("n", "gd", function()
vim.lsp.buf.definition()
end, opts)
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover()
end, opts)
vim.keymap.set("n", "<leader>vws", function()
vim.lsp.buf.workspace_symbol()
end, opts)
vim.keymap.set("n", "<leader>vd", function()
vim.diagnostic.open_float()
end, opts)
vim.keymap.set("n", "[d", function()
vim.diagnostic.goto_next()
end, opts)
vim.keymap.set("n", "]d", function()
vim.diagnostic.goto_prev()
end, opts)
vim.keymap.set("n", "<leader>vca", function()
vim.lsp.buf.code_action()
end, opts)
vim.keymap.set("n", "<leader>vrr", function()
vim.lsp.buf.references()
end, opts)
vim.keymap.set("n", "<leader>vrn", function()
vim.lsp.buf.rename()
end, opts)
vim.keymap.set("i", "<C-h>", function()
vim.lsp.buf.signature_help()
end, opts)
end)
vim.diagnostic.config({
virtual_text = true
virtual_text = true,
})
require("mason").setup({})
require("mason-lspconfig").setup({
ensure_installed = { 'lua_ls' },
ensure_installed = { "lua_ls" },
handlers = {
lsp.default_setup,
}
},
})

View File

@ -1,4 +1,4 @@
require('mini.indentscope').setup({
require("mini.indentscope").setup({
symbol = "",
options = { try_as_border = true },
})

View File

@ -6,5 +6,5 @@ require("mkdnflow").setup({
},
links = {
conceal = true,
}
},
})

View File

@ -1,7 +1,7 @@
require("oil").setup({
view_options = {
show_hidden = true
}
show_hidden = true,
},
})
vim.keymap.set("n", "<leader>e", "<CMD>Oil<CR>", { desc = "Open parent directory" })

View File

@ -1,7 +1,7 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, { desc = "Find files" })
vim.keymap.set('n', '<C-p>', builtin.git_files, { desc = "Find git files" })
vim.keymap.set('n', '<leader>ps', function()
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>pf", builtin.find_files, { desc = "Find files" })
vim.keymap.set("n", "<C-p>", builtin.git_files, { desc = "Find git files" })
vim.keymap.set("n", "<leader>ps", function()
builtin.grep_string({ search = vim.fn.input("Grep > ") })
end, { desc = "Find string" })
vim.keymap.set('n', '<leader>vh', builtin.help_tags, { desc = "Find help tags" })
vim.keymap.set("n", "<leader>vh", builtin.help_tags, { desc = "Find help tags" })

View File

@ -1,4 +1,4 @@
require 'nvim-treesitter.configs'.setup {
require("nvim-treesitter.configs").setup({
ensure_installed = { "lua", "bash" },
sync_install = false,
auto_install = true,
@ -7,4 +7,4 @@ require 'nvim-treesitter.configs'.setup {
enable = true,
additional_vim_regex_highlighting = false,
},
}
})

View File

@ -1 +1 @@
require('crony')
require("crony")

View File

@ -1,6 +1,6 @@
require('crony.set')
require('crony.map')
require('crony.lazy')
require("crony.set")
require("crony.map")
require("crony.lazy")
local autocmd = vim.api.nvim_create_autocmd

View File

@ -13,46 +13,46 @@ end
vim.opt.rtp:prepend(lazypath)
-- plugins installation and configuration
require('lazy').setup({
require("lazy").setup({
-- Git plugins
'tpope/vim-fugitive',
"tpope/vim-fugitive",
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x',
"VonHeikemen/lsp-zero.nvim",
branch = "v3.x",
dependencies = {
-- LSP Support
{ 'neovim/nvim-lspconfig' },
{ 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' },
{ "neovim/nvim-lspconfig" },
{ "williamboman/mason.nvim" },
{ "williamboman/mason-lspconfig.nvim" },
-- Autocompletion
{ 'hrsh7th/nvim-cmp' },
{ 'hrsh7th/cmp-buffer' },
{ 'hrsh7th/cmp-path' },
{ 'saadparwaiz1/cmp_luasnip' },
{ 'hrsh7th/cmp-nvim-lsp' },
{ 'hrsh7th/cmp-nvim-lua' },
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "saadparwaiz1/cmp_luasnip" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
-- Snippets
{ 'L3MON4D3/LuaSnip' },
{ 'rafamadriz/friendly-snippets' },
{ "L3MON4D3/LuaSnip" },
{ "rafamadriz/friendly-snippets" },
-- Nice lsp info
{ 'j-hui/fidget.nvim', opts = {} },
{ "j-hui/fidget.nvim", opts = {} },
-- Additional neovim docs
'folke/neodev.nvim',
"folke/neodev.nvim",
opts = {},
}
},
},
-- Emacs which key but in a much nicer form
{ 'folke/which-key.nvim', opts = {}, event = "VeryLazy" },
{ "folke/which-key.nvim", opts = {}, event = "VeryLazy" },
{
-- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
"lewis6991/gitsigns.nvim",
},
{
@ -64,49 +64,48 @@ require('lazy').setup({
{
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
"nvim-lualine/lualine.nvim",
-- See `:help lualine.txt`
opts = {
options = {
icons_enabled = false,
theme = 'catppuccin',
component_separators = '|',
section_separators = '',
theme = "catppuccin",
component_separators = "|",
section_separators = "",
},
},
},
{
-- show indent line
'lukas-reineke/indent-blankline.nvim',
"lukas-reineke/indent-blankline.nvim",
},
-- highlight indentscope
"echasnovski/mini.indentscope",
-- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {}, event = "VeryLazy" },
{ "numToStr/Comment.nvim", opts = {}, event = "VeryLazy" },
-- Fuzzy Finder (files, lsp, etc)
{
'nvim-telescope/telescope.nvim',
"nvim-telescope/telescope.nvim",
lazy = true,
dependencies = {
'nvim-lua/plenary.nvim',
"nvim-lua/plenary.nvim",
},
},
{
-- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
},
{
-- netrw on crack
'stevearc/oil.nvim',
opts = {
},
"stevearc/oil.nvim",
opts = {},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons", lazy = true },
},
@ -116,8 +115,8 @@ require('lazy').setup({
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
requires = { "nvim-lua/plenary.nvim", lazy = true }
}
requires = { "nvim-lua/plenary.nvim", lazy = true },
},
},
"NvChad/nvim-colorizer.lua",
@ -132,24 +131,27 @@ require('lazy').setup({
},
-- nice tmux integration
'christoomey/vim-tmux-navigator',
"christoomey/vim-tmux-navigator",
-- smart autopairs
'windwp/nvim-autopairs',
"windwp/nvim-autopairs",
{
-- nicer notification's
'rcarriga/nvim-notify',
"rcarriga/nvim-notify",
config = function()
vim.notify = require("notify")
end
end,
},
-- markdown editing super powered
'jakewvincent/mkdnflow.nvim',
"jakewvincent/mkdnflow.nvim",
-- additional formater support
"stevearc/conform.nvim",
}, {
install = {
colorscheme = { "catppuccin" }
colorscheme = { "catppuccin" },
},
performance = {
rtp = {
@ -160,7 +162,7 @@ require('lazy').setup({
"tohtml",
"tutor",
"zipPlugin",
}
}
}
},
},
},
})

View File

@ -1,17 +1,17 @@
local map = vim.keymap.set
-- Leader
vim.g.mapleader = ' '
vim.g.maplocalleader = ';'
vim.g.mapleader = " "
vim.g.maplocalleader = ";"
-- Diagnostic keymaps
map('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
map('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
map('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
map('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
map("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" })
map("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" })
map("n", "<leader>e", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
map("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" })
-- Lsp format
map('n', '<leader>f', vim.lsp.buf.format, { desc = "Format current buffer" })
-- map('n', '<leader>f', vim.lsp.buf.format, { desc = "Format current buffer" })
-- Move text easilly
map("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selected text up" })

View File

@ -18,7 +18,7 @@ opt.expandtab = true
opt.smartindent = true
-- Enable the mouse, just to have it
opt.mouse = 'a'
opt.mouse = "a"
-- Enable break indent
opt.breakindent = true
@ -34,14 +34,14 @@ opt.ignorecase = true
opt.smartcase = true
-- Keep signcolumn on by default
opt.signcolumn = 'yes'
opt.signcolumn = "yes"
-- Decrease update time
opt.updatetime = 50
opt.timeoutlen = 300
-- Set completeopt to have a better completion experience
opt.completeopt = 'menuone,noselect'
opt.completeopt = "menuone,noselect"
-- Enable true color support
opt.termguicolors = true