Expand tab with 4 spaces and change colorscheme to gruvbox

This commit is contained in:
Arkaprabha Chakraborty
2024-09-30 23:06:35 +05:30
parent 4ee3e596f9
commit c4d98040ca
11 changed files with 532 additions and 532 deletions

View File

@@ -1,140 +1,140 @@
-- Bootstrap lazy.nvim and load plugins -- Bootstrap lazy.nvim and load plugins
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", "--branch=stable",
lazypath, lazypath,
}) })
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
-- plugins to load -- plugins to load
local plugins = { local plugins = {
-- Appearance -- Appearance
{ {
"hardhackerlabs/theme-vim", "hardhackerlabs/theme-vim",
name = "hardhacker", name = "hardhacker",
lazy = false, lazy = false,
priority = 1000, priority = 1000,
config = function() config = function()
vim.g.hardhacker_hide_tilde = 1 vim.g.hardhacker_hide_tilde = 1
vim.g.hardhacker_keyword_italic = 1 vim.g.hardhacker_keyword_italic = 1
vim.g.hardhacker_custom_highlights = {} vim.g.hardhacker_custom_highlights = {}
vim.cmd("colorscheme hardhacker") vim.cmd("colorscheme hardhacker")
end, end,
}, },
{ "ellisonleao/gruvbox.nvim", priority = 1000, config = true }, { "ellisonleao/gruvbox.nvim", priority = 1000, config = true },
{ {
"navarasu/onedark.nvim", "navarasu/onedark.nvim",
config = { config = {
style = "warmer", style = "warmer",
transparent = true, transparent = true,
term_colors = true, term_colors = true,
ending_tildes = false, ending_tildes = false,
cmp_itemkind_reverse = false, cmp_itemkind_reverse = false,
toggle_style_key = nil, toggle_style_key = nil,
toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" },
code_style = { code_style = {
comments = "italic", comments = "italic",
keywords = "none", keywords = "none",
functions = "none", functions = "none",
strings = "none", strings = "none",
variables = "none", variables = "none",
}, },
lualine = { transparent = false }, lualine = { transparent = false },
colors = {}, colors = {},
highlights = {}, highlights = {},
diagnostics = { diagnostics = {
darker = true, darker = true,
undercurl = true, undercurl = true,
background = true, background = true,
}, },
}, },
}, },
{ "EdenEast/nightfox.nvim" }, { "EdenEast/nightfox.nvim" },
{ "rebelot/kanagawa.nvim" }, { "rebelot/kanagawa.nvim" },
{ "savq/melange-nvim" }, { "savq/melange-nvim" },
-- UI -- UI
{ "folke/zen-mode.nvim" }, { "folke/zen-mode.nvim" },
{ "nvim-lualine/lualine.nvim" }, { "nvim-lualine/lualine.nvim" },
{ "stevearc/dressing.nvim", event = "VeryLazy" }, { "stevearc/dressing.nvim", event = "VeryLazy" },
{ {
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
version = "*", version = "*",
dependencies = "nvim-tree/nvim-web-devicons", dependencies = "nvim-tree/nvim-web-devicons",
config = true, config = true,
}, },
{ {
"akinsho/toggleterm.nvim", "akinsho/toggleterm.nvim",
version = "*", version = "*",
opts = { opts = {
size = function(term) size = function(term)
if term.direction == "horizontal" then if term.direction == "horizontal" then
return 24 return 24
elseif term.direction == "vertical" then elseif term.direction == "vertical" then
return vim.o.columns * 0.4 return vim.o.columns * 0.4
end end
end, end,
open_mapping = [[<C-\>]], open_mapping = [[<C-\>]],
hide_numbers = true, hide_numbers = true,
start_in_insert = true, start_in_insert = true,
direction = "tab", direction = "tab",
close_on_exit = true, close_on_exit = true,
shell = vim.o.shell, shell = vim.o.shell,
float_opts = { border = "curved" }, float_opts = { border = "curved" },
}, },
}, },
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
branch = "v3.x", branch = "v3.x",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
"3rd/image.nvim", "3rd/image.nvim",
}, },
config = { hijack_netrw_behavior = "open_default" }, config = { hijack_netrw_behavior = "open_default" },
}, },
-- Git -- Git
{ "lewis6991/gitsigns.nvim" }, { "lewis6991/gitsigns.nvim" },
-- LSP and Completion -- LSP and Completion
{ "williamboman/mason.nvim" }, { "williamboman/mason.nvim" },
{ "williamboman/mason-lspconfig.nvim" }, { "williamboman/mason-lspconfig.nvim" },
{ "neovim/nvim-lspconfig" }, { "neovim/nvim-lspconfig" },
{ "jose-elias-alvarez/null-ls.nvim" }, { "jose-elias-alvarez/null-ls.nvim" },
{ "L3MON4D3/LuaSnip" }, { "L3MON4D3/LuaSnip" },
{ "rafamadriz/friendly-snippets" }, { "rafamadriz/friendly-snippets" },
{ "hrsh7th/nvim-cmp" }, { "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" }, { "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" }, { "hrsh7th/cmp-path" },
{ "saadparwaiz1/cmp_luasnip" }, { "saadparwaiz1/cmp_luasnip" },
{ "onsails/lspkind.nvim" }, { "onsails/lspkind.nvim" },
{ "hrsh7th/cmp-nvim-lsp" }, { "hrsh7th/cmp-nvim-lsp" },
-- Treesitter -- Treesitter
{ "nvim-treesitter/nvim-treesitter" }, { "nvim-treesitter/nvim-treesitter" },
{ "simrat39/rust-tools.nvim" }, { "simrat39/rust-tools.nvim" },
-- Misc -- Misc
{ "norcalli/nvim-colorizer.lua" }, { "norcalli/nvim-colorizer.lua" },
{ "github/copilot.vim" }, { "github/copilot.vim" },
-- Telescope -- Telescope
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
branch = "0.1.x", branch = "0.1.x",
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" },
}, },
}, },
} }
-- options -- options

View File

@@ -1,126 +1,126 @@
local cmp_status_ok, cmp = pcall(require, "cmp") local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then if not cmp_status_ok then
return return
end end
local snip_status_ok, luasnip = pcall(require, "luasnip") local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then if not snip_status_ok then
return return
end end
require("luasnip/loaders/from_vscode").lazy_load() require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function() local check_backspace = function()
local col = vim.fn.col(".") - 1 local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end end
local kind_icons = { local kind_icons = {
Text = "󰉿", Text = "󰉿",
Method = "󰆧", Method = "󰆧",
Function = "󰊕", Function = "󰊕",
Constructor = "", Constructor = "",
Field = "", Field = "",
Variable = "󰀫", Variable = "󰀫",
Class = "󰠱", Class = "󰠱",
Interface = "", Interface = "",
Module = "", Module = "",
Property = "󰜢", Property = "󰜢",
Unit = "󰑭", Unit = "󰑭",
Value = "󰎠", Value = "󰎠",
Enum = "", Enum = "",
Keyword = "󰌋", Keyword = "󰌋",
Snippet = "", Snippet = "",
Color = "󰏘", Color = "󰏘",
File = "󰈙", File = "󰈙",
Reference = "", Reference = "",
Folder = "󰉋", Folder = "󰉋",
EnumMember = "", EnumMember = "",
Constant = "󰏿", Constant = "󰏿",
Struct = "", Struct = "",
Event = "", Event = "",
Operator = "󰆕", Operator = "󰆕",
TypeParameter = "", TypeParameter = "",
Misc = "", Misc = "",
} }
-- find more here: https://www.nerdfonts.com/cheat-sheet -- find more here: https://www.nerdfonts.com/cheat-sheet
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users. luasnip.lsp_expand(args.body) -- For `luasnip` users.
end, end,
}, },
mapping = { mapping = {
["<C-k>"] = cmp.mapping.select_prev_item(), ["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(), ["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), ["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. ["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping({ ["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(), i = cmp.mapping.abort(),
c = cmp.mapping.close(), c = cmp.mapping.close(),
}), }),
-- Accept currently selected item. If none selected, `select` first item. -- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items. -- Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = cmp.mapping.confirm({ select = true }), ["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expandable() then elseif luasnip.expandable() then
luasnip.expand() luasnip.expand()
elseif luasnip.expand_or_jumpable() then elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
elseif check_backspace() then elseif check_backspace() then
fallback() fallback()
else else
fallback() fallback()
end end
end, { end, {
"i", "i",
"s", "s",
}), }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, { end, {
"i", "i",
"s", "s",
}), }),
}, },
formatting = { formatting = {
fields = { "kind", "abbr", "menu" }, fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item) format = function(entry, vim_item)
-- Kind icons -- Kind icons
vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({ vim_item.menu = ({
nvim_lsp = "[LSP]", nvim_lsp = "[LSP]",
luasnip = "[Snippet]", luasnip = "[Snippet]",
buffer = "[Buffer]", buffer = "[Buffer]",
path = "[Path]", path = "[Path]",
})[entry.source.name] })[entry.source.name]
return vim_item return vim_item
end, end,
}, },
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "buffer" }, { name = "buffer" },
{ name = "path" }, { name = "path" },
}, },
confirm_opts = { confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = false, select = false,
}, },
experimental = { experimental = {
ghost_text = false, ghost_text = false,
native_menu = false, native_menu = false,
}, },
}) })

View File

@@ -1,8 +1,8 @@
local ok, _ = pcall(require, "hardhacker") local ok, _ = pcall(require, "gruvbox")
if not ok then if not ok then
return return
end end
-- setup must be called before loading -- setup must be called before loading
vim.opt.termguicolors = true vim.opt.termguicolors = true
vim.cmd.colorscheme("hardhacker") vim.cmd.colorscheme("gruvbox")

View File

@@ -1,47 +1,47 @@
local ok, gitsigns = pcall(require, "gitsigns") local ok, gitsigns = pcall(require, "gitsigns")
if not ok then if not ok then
return return
end end
gitsigns.setup({ gitsigns.setup({
signs = { signs = {
add = { text = "" }, add = { text = "" },
change = { text = "" }, change = { text = "" },
delete = { text = "_" }, delete = { text = "_" },
topdelete = { text = "" }, topdelete = { text = "" },
changedelete = { text = "~" }, changedelete = { text = "~" },
untracked = { text = "" }, untracked = { text = "" },
}, },
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl` numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl` linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = { watch_gitdir = {
interval = 1000, interval = 1000,
follow_files = true, follow_files = true,
}, },
attach_to_untracked = true, attach_to_untracked = true,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = { current_line_blame_opts = {
virt_text = true, virt_text = true,
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
delay = 1000, delay = 1000,
ignore_whitespace = false, ignore_whitespace = false,
}, },
current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>", current_line_blame_formatter = "<author>, <author_time:%Y-%m-%d> - <summary>",
sign_priority = 6, sign_priority = 6,
update_debounce = 100, update_debounce = 100,
status_formatter = nil, -- Use default status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines) max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = { preview_config = {
-- Options passed to nvim_open_win -- Options passed to nvim_open_win
border = "single", border = "single",
style = "minimal", style = "minimal",
relative = "cursor", relative = "cursor",
row = 0, row = 0,
col = 1, col = 1,
}, },
yadm = { yadm = {
enable = false, enable = false,
}, },
}) })

View File

@@ -1,45 +1,45 @@
local ok, lualine = pcall(require, "lualine") local ok, lualine = pcall(require, "lualine")
if not ok then if not ok then
return return
end end
lualine.setup({ lualine.setup({
options = { options = {
icons_enabled = false, icons_enabled = false,
theme = "auto", theme = "auto",
component_separators = { left = "", right = "" }, component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" }, section_separators = { left = "", right = "" },
disabled_filetypes = { disabled_filetypes = {
statusline = {}, statusline = {},
winbar = {}, winbar = {},
}, },
ignore_focus = {}, ignore_focus = {},
always_divide_middle = true, always_divide_middle = true,
globalstatus = false, globalstatus = false,
refresh = { refresh = {
statusline = 1000, statusline = 1000,
tabline = 1000, tabline = 1000,
winbar = 1000, winbar = 1000,
}, },
}, },
sections = { sections = {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" }, lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" }, lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" }, lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" }, lualine_y = { "progress" },
lualine_z = { "location" }, lualine_z = { "location" },
}, },
inactive_sections = { inactive_sections = {
lualine_a = {}, lualine_a = {},
lualine_b = {}, lualine_b = {},
lualine_c = { "filename" }, lualine_c = { "filename" },
lualine_x = { "location" }, lualine_x = { "location" },
lualine_y = {}, lualine_y = {},
lualine_z = {}, lualine_z = {},
}, },
tabline = {}, tabline = {},
winbar = {}, winbar = {},
inactive_winbar = {}, inactive_winbar = {},
extensions = {}, extensions = {},
}) })

View File

@@ -1,35 +1,35 @@
local ok, null_ls = pcall(require, "null-ls") local ok, null_ls = pcall(require, "null-ls")
if not ok then if not ok then
return return
end end
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.rustfmt, null_ls.builtins.formatting.rustfmt,
null_ls.builtins.formatting.stylua, null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.black, null_ls.builtins.formatting.black,
null_ls.builtins.formatting.prettier, null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.clang_format, null_ls.builtins.formatting.clang_format,
}, },
-- you can reuse a shared lspconfig on_attach callback here -- you can reuse a shared lspconfig on_attach callback here
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({
bufnr = bufnr, bufnr = bufnr,
filter = function() filter = function()
return client.name == "null-ls" return client.name == "null-ls"
end, end,
}) })
end, end,
}) })
end end
end, end,
}) })

View File

@@ -1,93 +1,93 @@
local ok, cmp = pcall(require, "cmp") local ok, cmp = pcall(require, "cmp")
if not ok then if not ok then
return return
end end
local luasnip_ok, luasnip = pcall(require, "luasnip") local luasnip_ok, luasnip = pcall(require, "luasnip")
if not luasnip_ok then if not luasnip_ok then
return return
end end
local luasnip_vscode_ok, luasnip_vscode = pcall(require, "luasnip/loaders/from_vscode") local luasnip_vscode_ok, luasnip_vscode = pcall(require, "luasnip/loaders/from_vscode")
if not luasnip_vscode_ok then if not luasnip_vscode_ok then
return return
end end
local lspkind_ok, lspkind = pcall(require, "lspkind") local lspkind_ok, lspkind = pcall(require, "lspkind")
if not lspkind_ok then if not lspkind_ok then
return return
end end
luasnip_vscode.lazy_load() luasnip_vscode.lazy_load()
local has_words_before = function() local has_words_before = function()
unpack = unpack or table.unpack unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end end
cmp.setup({ cmp.setup({
view = { view = {
--entries = { name = "custom", selection_order = "near_cursor" }, --entries = { name = "custom", selection_order = "near_cursor" },
}, },
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users. luasnip.lsp_expand(args.body) -- For `luasnip` users.
end, end,
}, },
mapping = { mapping = {
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<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. ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region -- they way you will only jump inside the snippet region
elseif luasnip.expand_or_jumpable() then elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
elseif has_words_before() then elseif has_words_before() then
cmp.complete() cmp.complete()
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
}, },
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "buffer" }, { name = "buffer" },
{ name = "path" }, { name = "path" },
}, },
confirm_opts = { confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = false, select = false,
}, },
experimental = { experimental = {
ghost_text = false, ghost_text = false,
}, },
formatting = { formatting = {
fields = { "abbr", "kind", "menu" }, fields = { "abbr", "kind", "menu" },
format = function(entry, vim_item) format = function(entry, vim_item)
local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item) local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true }) local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " " kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = (strings[2] or "") kind.menu = (strings[2] or "")
return kind return kind
end, end,
}, },
}) })

View File

@@ -1,54 +1,54 @@
local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
if not lspconfig_status_ok then if not lspconfig_status_ok then
return return
end end
local mason_status_ok, mason = pcall(require, "mason") local mason_status_ok, mason = pcall(require, "mason")
if not mason_status_ok then if not mason_status_ok then
return return
end end
local mason_lspconfig_status_ok, mason_lspconfig = pcall(require, "mason-lspconfig") local mason_lspconfig_status_ok, mason_lspconfig = pcall(require, "mason-lspconfig")
if not mason_lspconfig_status_ok then if not mason_lspconfig_status_ok then
return return
end end
mason.setup({}) mason.setup({})
mason_lspconfig.setup({ mason_lspconfig.setup({
ensure_installed = { "lua_ls", "rust_analyzer", "clangd", "marksman" }, ensure_installed = { "lua_ls", "rust_analyzer", "clangd", "marksman" },
}) })
local cnl_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") local cnl_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not cnl_ok then if not cnl_ok then
return return
end end
local capabilities = cmp_nvim_lsp.default_capabilities() local capabilities = cmp_nvim_lsp.default_capabilities()
mason_lspconfig.setup_handlers({ mason_lspconfig.setup_handlers({
function(server) function(server)
lspconfig[server].setup({ lspconfig[server].setup({
capabilities = capabilities, capabilities = capabilities,
}) })
lspconfig.lua_ls.setup({ lspconfig.lua_ls.setup({
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
Lua = { Lua = {
diagnostics = { diagnostics = {
-- Get the language server to recognize the `vim` global -- Get the language server to recognize the `vim` global
globals = { "vim" }, globals = { "vim" },
}, },
}, },
}, },
}) })
end, end,
["rust_analyzer"] = function() ["rust_analyzer"] = function()
local rt_ok, rust_tools = pcall(require, "rust-tools") local rt_ok, rust_tools = pcall(require, "rust-tools")
if rt_ok then if rt_ok then
rust_tools.setup({}) rust_tools.setup({})
end end
end, end,
}) })
-- Global mappings. -- Global mappings.
@@ -61,30 +61,30 @@ vim.keymap.set("n", "<Leader>q", vim.diagnostic.setloclist)
-- Use LspAttach autocommand to only map the following keys -- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}), group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev) callback = function(ev)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
-- Buffer local mappings. -- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf } local opts = { buffer = ev.buf }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts) vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<Leader>wa", vim.lsp.buf.add_workspace_folder, opts) vim.keymap.set("n", "<Leader>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<Leader>wr", vim.lsp.buf.remove_workspace_folder, opts) vim.keymap.set("n", "<Leader>wr", vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<Leader>wl", function() vim.keymap.set("n", "<Leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workLeader_folders())) print(vim.inspect(vim.lsp.buf.list_workLeader_folders()))
end, opts) end, opts)
vim.keymap.set("n", "<Leader>D", vim.lsp.buf.type_definition, opts) vim.keymap.set("n", "<Leader>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, opts) vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set({ "n", "v" }, "<Leader>ca", vim.lsp.buf.code_action, opts) vim.keymap.set({ "n", "v" }, "<Leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "<Leader>f", function() vim.keymap.set("n", "<Leader>f", function()
vim.lsp.buf.format({ async = true }) vim.lsp.buf.format({ async = true })
end, opts) end, opts)
end, end,
}) })

View File

@@ -1,48 +1,48 @@
local status_ok, telescope = pcall(require, "telescope") local status_ok, telescope = pcall(require, "telescope")
if not status_ok then if not status_ok then
return return
end end
local actions_ok, actions = pcall(require, "telescope.actions") local actions_ok, actions = pcall(require, "telescope.actions")
if not actions_ok then if not actions_ok then
return return
end end
telescope.setup({ telescope.setup({
defaults = { defaults = {
-- Default configuration for telescope goes here: -- Default configuration for telescope goes here:
-- config_key = value, -- config_key = value,
mappings = { mappings = {
i = { i = {
-- map telescope.actions.which_key to <C-h> (default: <C-/>) -- map telescope.actions.which_key to <C-h> (default: <C-/>)
-- telescope.actions.which_key shows the mappings for your picker, -- telescope.actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker -- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "which_key", ["<C-h>"] = "which_key",
["<C-k>"] = actions.move_selection_previous, ["<C-k>"] = actions.move_selection_previous,
["<C-j>"] = actions.move_selection_next, ["<C-j>"] = actions.move_selection_next,
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist, ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
}, },
}, },
}, },
pickers = { pickers = {
-- Default configuration for builtin pickers goes here: -- Default configuration for builtin pickers goes here:
-- picker_name = { -- picker_name = {
-- picker_config_key = value, -- picker_config_key = value,
-- ... -- ...
-- } -- }
-- Now the picker_config_key will be applied every time you call this -- Now the picker_config_key will be applied every time you call this
-- builtin picker -- builtin picker
find_files = { find_files = {
hidden = false, hidden = false,
}, },
}, },
extensions = { extensions = {
-- Your extension configuration goes here: -- Your extension configuration goes here:
-- extension_name = { -- extension_name = {
-- extension_config_key = value, -- extension_config_key = value,
-- } -- }
-- please take a look at the readme of the extension you want to configure -- please take a look at the readme of the extension you want to configure
}, },
}) })
telescope.load_extension("fzf") telescope.load_extension("fzf")

View File

@@ -2,13 +2,13 @@
-- This function is taken from https://github.com/norcalli/nvim_utils -- This function is taken from https://github.com/norcalli/nvim_utils
local function nvim_create_augroups(definitions) local function nvim_create_augroups(definitions)
for group_name, definition in pairs(definitions) do for group_name, definition in pairs(definitions) do
vim.api.nvim_command('augroup ' .. group_name) vim.api.nvim_command("augroup " .. group_name)
vim.api.nvim_command('autocmd!') vim.api.nvim_command("autocmd!")
for _, def in ipairs(definition) do for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten { 'autocmd', def }, ' ') local command = table.concat(vim.tbl_flatten({ "autocmd", def }), " ")
vim.api.nvim_command(command) vim.api.nvim_command(command)
end end
vim.api.nvim_command('augroup END') vim.api.nvim_command("augroup END")
end end
end end

View File

@@ -1,42 +1,42 @@
local ok, nvim_treesitter = pcall(require, "nvim-treesitter.configs") local ok, nvim_treesitter = pcall(require, "nvim-treesitter.configs")
if not ok then if not ok then
return return
end end
nvim_treesitter.setup({ nvim_treesitter.setup({
-- A list of parser names, or "all" (the four listed parsers should always be installed) -- A list of parser names, or "all" (the four listed parsers should always be installed)
ensure_installed = { "c", "lua", "vim", "cpp", "rust" }, ensure_installed = { "c", "lua", "vim", "cpp", "rust" },
-- Install parsers synchronously (only applied to `ensure_installed`) -- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false, sync_install = false,
-- Automatically install missing parsers when entering buffer -- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true, auto_install = true,
-- List of parsers to ignore installing (for "all") -- List of parsers to ignore installing (for "all")
ignore_install = { "javascript" }, ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup) ---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = { highlight = {
enable = true, enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser) -- the name of the parser)
-- list of language that will be disabled -- list of language that will be disabled
disable = { "" }, disable = { "" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
--disable = function(lang, buf) --disable = function(lang, buf)
-- local max_filesize = 100 * 1024 -- 100 KB -- local max_filesize = 100 * 1024 -- 100 KB
-- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) -- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
-- if ok and stats and stats.size > max_filesize then -- if ok and stats and stats.size > max_filesize then
-- return true -- return true
-- end -- end
--end, --end,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights. -- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages -- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = true, additional_vim_regex_highlighting = true,
}, },
indent = { enable = true, disable = { "yaml" } }, indent = { enable = true, disable = { "yaml" } },
}) })