2023-05-14 10:23:49 +01:00
|
|
|
vim.g.mapleader = ","
|
|
|
|
|
|
|
|
-- 4 space tabs
|
|
|
|
vim.o.expandtab = true
|
2023-05-17 19:46:17 +01:00
|
|
|
vim.o.shiftwidth = 2
|
|
|
|
vim.o.tabstop = 2
|
2023-05-14 10:23:49 +01:00
|
|
|
vim.o.smartindent = true
|
|
|
|
|
2023-05-26 02:42:33 +01:00
|
|
|
vim.o.background = "dark"
|
2023-05-14 10:23:49 +01:00
|
|
|
vim.o.clipboard = "unnamedplus"
|
|
|
|
vim.o.termguicolors = true
|
|
|
|
vim.o.ignorecase = true
|
|
|
|
vim.o.smartcase = true
|
|
|
|
vim.o.lazyredraw = true
|
2023-05-15 21:06:28 +01:00
|
|
|
vim.o.timeoutlen = 100
|
2023-05-14 10:23:49 +01:00
|
|
|
|
|
|
|
vim.wo.number = true
|
|
|
|
vim.wo.relativenumber = true
|
|
|
|
|
2023-05-26 02:42:33 +01:00
|
|
|
require("gruvbox").setup({
|
|
|
|
transparent_mode = true
|
2023-05-17 19:46:17 +01:00
|
|
|
})
|
2023-05-26 02:42:33 +01:00
|
|
|
vim.cmd("colorscheme gruvbox")
|
2023-05-14 10:23:49 +01:00
|
|
|
|
|
|
|
require("lualine").setup({
|
2023-05-17 19:46:17 +01:00
|
|
|
options = {
|
2023-05-26 02:42:33 +01:00
|
|
|
theme = "gruvbox_dark",
|
2023-05-17 19:46:17 +01:00
|
|
|
}
|
2023-05-14 10:23:49 +01:00
|
|
|
})
|
|
|
|
|
2023-05-21 01:35:32 +01:00
|
|
|
require("dressing").setup()
|
|
|
|
|
2023-05-14 10:23:49 +01:00
|
|
|
require("bufferline").setup({
|
2023-05-17 19:46:17 +01:00
|
|
|
options = {
|
|
|
|
show_tab_indicators = true,
|
2023-05-20 18:42:57 +01:00
|
|
|
-- separator_style = { "", "" },
|
|
|
|
indicator = { style = "icon", icon = "▎" },
|
|
|
|
color_icons = true,
|
|
|
|
offsets = {
|
|
|
|
{
|
|
|
|
filetype = "neo-tree",
|
|
|
|
text = "File Explorer",
|
|
|
|
text_align = "center",
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
},
|
2023-05-17 19:46:17 +01:00
|
|
|
},
|
2023-05-14 10:23:49 +01:00
|
|
|
})
|
|
|
|
|
2023-05-25 22:47:29 +01:00
|
|
|
require("colorizer").setup({})
|
|
|
|
require("nvim-autopairs").setup({})
|
|
|
|
require("Comment").setup({})
|
2023-05-14 10:23:49 +01:00
|
|
|
|
|
|
|
require("neo-tree").setup({
|
2023-05-17 19:46:17 +01:00
|
|
|
default_component_configs = {
|
|
|
|
icon = {
|
|
|
|
folder_empty = "",
|
|
|
|
folder_empty_open = "",
|
2023-05-14 10:23:49 +01:00
|
|
|
},
|
2023-05-17 19:46:17 +01:00
|
|
|
git_status = {
|
|
|
|
symbols = {
|
|
|
|
renamed = "",
|
|
|
|
unstaged = "",
|
|
|
|
},
|
2023-05-14 10:23:49 +01:00
|
|
|
},
|
2023-05-17 19:46:17 +01:00
|
|
|
},
|
|
|
|
document_symbols = {
|
|
|
|
kinds = {
|
|
|
|
File = { icon = "", hl = "Tag" },
|
|
|
|
Namespace = { icon = "", hl = "Include" },
|
|
|
|
Package = { icon = "", hl = "Label" },
|
|
|
|
Class = { icon = "", hl = "Include" },
|
|
|
|
Property = { icon = "", hl = "@property" },
|
|
|
|
Enum = { icon = "", hl = "@number" },
|
|
|
|
Function = { icon = "", hl = "Function" },
|
|
|
|
String = { icon = "", hl = "String" },
|
|
|
|
Number = { icon = "", hl = "Number" },
|
|
|
|
Array = { icon = "", hl = "Type" },
|
|
|
|
Object = { icon = "", hl = "Type" },
|
|
|
|
Key = { icon = "", hl = "" },
|
|
|
|
Struct = { icon = "", hl = "Type" },
|
|
|
|
Operator = { icon = "", hl = "Operator" },
|
|
|
|
TypeParameter = { icon = "", hl = "Type" },
|
|
|
|
StaticMethod = { icon = ' ', hl = 'Function' },
|
|
|
|
}
|
|
|
|
},
|
2023-05-14 10:23:49 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
require("nvim-treesitter.configs").setup({
|
2023-05-17 19:46:17 +01:00
|
|
|
highlight = { enable = true, },
|
2023-05-14 10:23:49 +01:00
|
|
|
})
|
|
|
|
|
2023-05-15 21:06:28 +01:00
|
|
|
require("which-key").setup()
|
|
|
|
|
2023-05-21 21:21:25 +01:00
|
|
|
require("trouble").setup()
|
2023-05-15 21:06:28 +01:00
|
|
|
|
2023-05-21 21:21:25 +01:00
|
|
|
local telescope = require("telescope")
|
|
|
|
local telescope_builtin = require("telescope.builtin")
|
|
|
|
|
|
|
|
telescope.load_extension("fzf")
|
2023-05-14 10:23:49 +01:00
|
|
|
|
2023-05-21 01:35:32 +01:00
|
|
|
require('nvim-surround').setup()
|
|
|
|
|
|
|
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
2023-05-25 22:47:29 +01:00
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
|
2023-05-17 19:46:17 +01:00
|
|
|
local lspconfig = require("lspconfig")
|
2023-05-21 21:21:25 +01:00
|
|
|
lspconfig.nil_ls.setup {
|
2023-05-21 22:52:56 +01:00
|
|
|
capabilities = capabilities,
|
2023-05-21 01:35:32 +01:00
|
|
|
}
|
2023-05-17 19:46:17 +01:00
|
|
|
lspconfig.lua_ls.setup {
|
2023-05-21 01:35:32 +01:00
|
|
|
capabilities = capabilities,
|
2023-05-17 19:46:17 +01:00
|
|
|
settings = {
|
|
|
|
Lua = {
|
2023-05-25 22:47:29 +01:00
|
|
|
runtime = { version = "LuaJIT" },
|
|
|
|
diagnostics = { globals = { "vim" } },
|
|
|
|
workspace = {
|
|
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
|
|
checkThirdParty = false
|
2023-05-17 19:46:17 +01:00
|
|
|
},
|
2023-05-25 22:47:29 +01:00
|
|
|
telemetry = { enable = false },
|
2023-05-17 19:46:17 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2023-05-25 15:44:15 +01:00
|
|
|
|
2023-05-25 22:47:29 +01:00
|
|
|
lspconfig.clangd.setup { capabilities = capabilities }
|
|
|
|
lspconfig.rust_analyzer.setup { capabilities = capabilities }
|
2023-05-17 19:46:17 +01:00
|
|
|
|
2023-05-25 22:47:29 +01:00
|
|
|
lspconfig.cssls.setup {
|
2023-05-25 15:44:15 +01:00
|
|
|
capabilities = capabilities,
|
2023-05-25 22:47:29 +01:00
|
|
|
cmd = { "css-languageserver", "--stdio" },
|
|
|
|
settings = {
|
|
|
|
css = { validate = false },
|
|
|
|
}
|
2023-05-25 15:44:15 +01:00
|
|
|
}
|
|
|
|
|
2023-05-21 01:35:32 +01:00
|
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
|
|
|
|
|
|
|
local has_words_before = function()
|
|
|
|
unpack = unpack or table.unpack
|
|
|
|
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
|
|
|
|
end
|
|
|
|
|
2023-05-14 10:23:49 +01:00
|
|
|
local cmp = require("cmp")
|
2023-05-21 01:35:32 +01:00
|
|
|
|
2023-05-14 10:23:49 +01:00
|
|
|
local lspkind = require("lspkind")
|
2023-05-21 01:35:32 +01:00
|
|
|
local luasnip = require("luasnip")
|
2023-05-14 10:23:49 +01:00
|
|
|
cmp.setup({
|
2023-05-17 19:46:17 +01:00
|
|
|
preselect = cmp.PreselectMode.None,
|
|
|
|
formatting = {
|
|
|
|
format = lspkind.cmp_format ({
|
2023-05-25 22:47:29 +01:00
|
|
|
mode = "symbol_text",
|
2023-05-17 19:46:17 +01:00
|
|
|
|
|
|
|
symbol_map = {
|
|
|
|
Text = "",
|
|
|
|
Method = "",
|
|
|
|
Function = "",
|
|
|
|
Constructor = "",
|
|
|
|
Field = "",
|
|
|
|
Variable = "",
|
|
|
|
Class = "",
|
|
|
|
Interface = "",
|
|
|
|
Module = "",
|
|
|
|
Property = "",
|
|
|
|
Unit = "",
|
|
|
|
Value = "",
|
|
|
|
Enum = "",
|
|
|
|
Keyword = "",
|
|
|
|
Snippet = "",
|
|
|
|
Color = "",
|
|
|
|
File = "",
|
|
|
|
Reference = "",
|
|
|
|
Folder = "",
|
|
|
|
EnumMember = "",
|
|
|
|
Constant = "",
|
|
|
|
Struct = "",
|
|
|
|
Event = "",
|
|
|
|
Operator = "",
|
|
|
|
TypeParameter = ""
|
|
|
|
},
|
2023-05-14 10:23:49 +01:00
|
|
|
}),
|
2023-05-17 19:46:17 +01:00
|
|
|
},
|
|
|
|
|
2023-05-21 01:35:32 +01:00
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
require('luasnip').lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
|
2023-05-17 19:46:17 +01:00
|
|
|
window = {
|
|
|
|
completion = cmp.config.window.bordered(),
|
|
|
|
documentation = cmp.config.window.bordered(),
|
|
|
|
},
|
|
|
|
|
|
|
|
sources = cmp.config.sources ({
|
|
|
|
{ name = "buffer" },
|
|
|
|
{ name = "path" },
|
|
|
|
{ name = "nvim_lsp" },
|
2023-05-21 01:35:32 +01:00
|
|
|
{ name = "luasnip" },
|
2023-05-17 19:46:17 +01:00
|
|
|
}),
|
|
|
|
|
|
|
|
mapping = cmp.mapping.preset.insert({
|
|
|
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
|
|
['<C-e>'] = cmp.mapping.abort(),
|
|
|
|
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
2023-05-21 01:35:32 +01:00
|
|
|
|
|
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
|
|
|
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
|
|
|
-- they way you will only jump inside the snippet region
|
|
|
|
elseif luasnip.expand_or_jumpable() then
|
|
|
|
luasnip.expand_or_jump()
|
|
|
|
elseif has_words_before() then
|
|
|
|
cmp.complete()
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, { "i", "s" }),
|
|
|
|
|
|
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_prev_item()
|
|
|
|
elseif luasnip.jumpable(-1) then
|
|
|
|
luasnip.jump(-1)
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, { "i", "s" }),
|
2023-05-17 19:46:17 +01:00
|
|
|
}),
|
2023-05-14 10:23:49 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
|
|
|
cmp.event:on(
|
2023-05-21 01:35:32 +01:00
|
|
|
'confirm_done',
|
|
|
|
cmp_autopairs.on_confirm_done()
|
2023-05-14 10:23:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
cmp.setup.cmdline(":", {
|
2023-05-17 19:46:17 +01:00
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = "path" },
|
|
|
|
{ name = "cmdline" },
|
|
|
|
})
|
2023-05-14 10:23:49 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
cmp.setup.cmdline("/", {
|
2023-05-17 19:46:17 +01:00
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = "buffer" },
|
|
|
|
})
|
2023-05-14 10:23:49 +01:00
|
|
|
})
|
2023-05-21 01:35:32 +01:00
|
|
|
-- keymaps
|
|
|
|
vim.keymap.set("n", "<C-n>", "<cmd>NeoTreeFocusToggle<CR>")
|
|
|
|
|
|
|
|
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Go to left window" })
|
|
|
|
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" })
|
|
|
|
vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Go to upper window" })
|
|
|
|
vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Go to right window" })
|
|
|
|
|
|
|
|
vim.keymap.set("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
|
|
|
|
vim.keymap.set("n", "<C-Down>", "<cmd>resize -2<cr>", { desc = "Decrease window height" })
|
|
|
|
vim.keymap.set("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "Decrease window width" })
|
|
|
|
vim.keymap.set("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Increase window width" })
|
|
|
|
|
|
|
|
vim.keymap.set("n", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
|
|
|
vim.keymap.set("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
|
|
|
vim.keymap.set("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
|
|
|
vim.keymap.set("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
|
|
|
vim.keymap.set("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
|
|
|
vim.keymap.set("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
|
|
|
vim.keymap.set({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
|
|
|
|
|
|
|
|
vim.keymap.set("n", "<S-h>", "<cmd>BufferLineCyclePrev<cr>", { desc = "Prev buffer" })
|
|
|
|
vim.keymap.set("n", "<S-l>", "<cmd>BufferLineCycleNext<cr>", { desc = "Next buffer" })
|
|
|
|
vim.keymap.set("n", "[b", "<cmd>BufferLineCyclePrev<cr>", { desc = "Prev buffer" })
|
|
|
|
vim.keymap.set("n", "]b", "<cmd>BufferLineCycleNext<cr>", { desc = "Next buffer" })
|
2023-05-21 21:21:25 +01:00
|
|
|
|
|
|
|
vim.keymap.set("n", '<leader>ff', telescope_builtin.find_files, { desc = "Find Files" })
|
|
|
|
vim.keymap.set("n", '<leader>fg', telescope_builtin.live_grep, { desc = "Live Grep" })
|
|
|
|
vim.keymap.set("n", '<leader>fb', telescope_builtin.buffers, { desc = "List Buffers" })
|
|
|
|
vim.keymap.set("n", '<leader>fh', telescope_builtin.help_tags, { desc = "Help Tags" })
|
|
|
|
vim.keymap.set("n", '<leader>fc', telescope_builtin.git_files, { desc = "Find Files (Git)" })
|
|
|
|
|
|
|
|
vim.keymap.set("n", "<leader>xx", "<cmd>TroubleToggle<cr>", { silent = true, noremap = true, desc = "Toggle Trouble Window" })
|