summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorseth <[email protected]>2023-09-01 15:35:00 -0400
committerseth <[email protected]>2023-09-06 10:48:13 -0400
commit27bee5c6bc5ab8df93f2be20fc9e20ed6e71bd27 (patch)
tree2b1e8872f28aa51ca7c5a12ade51a3dca2de2bdf /lua
initial commit
Diffstat (limited to 'lua')
-rw-r--r--lua/getchoo/filetypes.lua8
-rw-r--r--lua/getchoo/init.lua21
-rw-r--r--lua/getchoo/keybinds.lua38
-rw-r--r--lua/getchoo/plugins/general.lua66
-rw-r--r--lua/getchoo/plugins/init.lua6
-rw-r--r--lua/getchoo/plugins/lazy.lua37
-rw-r--r--lua/getchoo/plugins/lsp.lua161
7 files changed, 337 insertions, 0 deletions
diff --git a/lua/getchoo/filetypes.lua b/lua/getchoo/filetypes.lua
new file mode 100644
index 0000000..cb62635
--- /dev/null
+++ b/lua/getchoo/filetypes.lua
@@ -0,0 +1,8 @@
+local filetypes = {
+ filename = {
+ PKGBUILD = "text",
+ [".makepkg.conf"] = "text",
+ },
+}
+
+vim.filetype.add(filetypes)
diff --git a/lua/getchoo/init.lua b/lua/getchoo/init.lua
new file mode 100644
index 0000000..94a02dc
--- /dev/null
+++ b/lua/getchoo/init.lua
@@ -0,0 +1,21 @@
+local cmd = vim.cmd
+local opt = vim.opt
+
+-- text options
+opt.tabstop = 2
+opt.shiftwidth = 2
+opt.expandtab = false
+opt.smartindent = true
+opt.wrap = false
+
+-- appearance
+opt.syntax = "on"
+cmd("filetype plugin indent on")
+opt.termguicolors = true
+
+require("getchoo.keybinds")
+require("getchoo.filetypes")
+
+if vim.g.no_plugins then
+ require("getchoo.plugins")
+end
diff --git a/lua/getchoo/keybinds.lua b/lua/getchoo/keybinds.lua
new file mode 100644
index 0000000..a71f606
--- /dev/null
+++ b/lua/getchoo/keybinds.lua
@@ -0,0 +1,38 @@
+vim.g.mapleader = ","
+
+local opts = { noremap = true, silent = true }
+local set = function(mode, key, vimcmd)
+ vim.keymap.set(mode, key, vimcmd, opts)
+end
+
+set("n", "<leader>t", function()
+ vim.cmd("NvimTreeToggle")
+end)
+
+for i = 1, 9 do
+ set("n", "<leader>" .. i, function()
+ local vimcmd = "BufferLineGoToBuffer " .. i
+ vim.cmd(vimcmd)
+ end)
+end
+
+set("n", "<leader>q", function()
+ vim.cmd("BufferLinePickClose")
+end)
+
+set("n", "<leader>e", vim.diagnostic.open_float)
+set("n", "[d", vim.diagnostic.goto_prev)
+set("n", "]d", vim.diagnostic.goto_next)
+set("n", "<leader>u", vim.diagnostic.setloclist)
+
+set("n", "<leader>f", function()
+ vim.cmd("Telescope")
+end)
+
+set("n", "<leader>p", function()
+ vim.cmd("TroubleToggle")
+end)
+
+set("n", "<leader>z", function()
+ vim.api.nvim_clear_autocmds({ group = "LspFormatting" })
+end)
diff --git a/lua/getchoo/plugins/general.lua b/lua/getchoo/plugins/general.lua
new file mode 100644
index 0000000..3c89ea6
--- /dev/null
+++ b/lua/getchoo/plugins/general.lua
@@ -0,0 +1,66 @@
+---- autopairs
+require("nvim-autopairs").setup({
+ disable_filetype = { "TeleScopePrompt" },
+})
+
+---- catppuccin
+local compile_path = vim.fn.stdpath("cache") .. "/catppuccin-nvim"
+vim.fn.mkdir(compile_path, "p")
+vim.opt.runtimepath:append(compile_path)
+
+require("catppuccin").setup({
+ compile_path = compile_path,
+ flavour = "mocha", -- mocha, macchiato, frappe, latte
+ integrations = {
+ barbar = true,
+ cmp = true,
+ gitsigns = true,
+ leap = true,
+ native_lsp = {
+ enabled = true,
+ },
+ nvimtree = true,
+ treesitter_context = true,
+ treesitter = true,
+ telescope = true,
+ lsp_trouble = true,
+ },
+ no_italic = true,
+})
+vim.api.nvim_command("colorscheme catppuccin")
+
+---- bufferline
+require("bufferline").setup({
+ options = {
+ always_show_bufferline = false,
+ highlights = require("catppuccin.groups.integrations.bufferline").get(),
+ diagnostics = "nvim_lsp",
+ mode = "buffers",
+ numbers = "ordinal",
+ separator_style = "slant",
+ },
+})
+
+---- gitsigns
+require("gitsigns").setup()
+
+---- leap
+require("leap").add_default_mappings()
+
+---- lualine
+require("lualine").setup({
+ options = {
+ theme = "catppuccin",
+ },
+ extensions = { "nvim-tree" },
+})
+
+---- nvim-tree
+require("nvim-tree").setup()
+
+---- treesitter
+require("nvim-treesitter.configs").setup({
+ auto_install = false,
+ highlight = { enable = true },
+ indent = { enable = true },
+})
diff --git a/lua/getchoo/plugins/init.lua b/lua/getchoo/plugins/init.lua
new file mode 100644
index 0000000..f0e8a44
--- /dev/null
+++ b/lua/getchoo/plugins/init.lua
@@ -0,0 +1,6 @@
+if vim.g.use_lazy then
+ require("getchoo.plugins.lazy")
+end
+
+require("getchoo.plugins.general")
+require("getchoo.plugins.lsp")
diff --git a/lua/getchoo/plugins/lazy.lua b/lua/getchoo/plugins/lazy.lua
new file mode 100644
index 0000000..bdd6dc3
--- /dev/null
+++ b/lua/getchoo/plugins/lazy.lua
@@ -0,0 +1,37 @@
+local lazy_path = vim.fn.stdpath("data") .. "/lazy/lazy.vim"
+
+-- bootstrap lazy
+if not vim.loop.fs_stat(lazy_path) then
+ vim.fn.system({
+ "git",
+ "clone",
+ "--filter=blob:none",
+ "https://github.com/folke/lazy.nvim.git",
+ "--branch=stable",
+ lazy_path,
+ })
+end
+
+vim.opt.rtp:prepend(lazy_path)
+
+require("lazy").setup({
+ { "akinsho/bufferline.nvim", version = "*", dependencies = "nvim-tree/nvim-web-devicons" },
+ { "catppuccin/nvim", name = "catppuccin", priority = 1000 },
+ "hrsh7th/nvim-cmp",
+ "hrsh7th/cmp-nvim-lsp",
+ "hrsh7th/cmp-buffer",
+ "saadparwaiz1/cmp_luasnip",
+ "FelipeLema/cmp-async-path",
+ { "j-hui/fidget.nvim", tag = "legacy" },
+ "lewis6991/gitsigns.nvim",
+ { "folke/flash.nvim", event = "VeryLazy" },
+ { "nvim-lualine/lualine.nvim", dependencies = "nvim-tree/nvim-web-devicons" },
+ "L3MON4D3/LuaSnip",
+ { "echasnovski/mini.pairs", event = "VeryLazy" },
+ "neovim/nvim-lspconfig",
+ { "nvim-tree/nvim-tree.lua", dependencies = "nvim-tree/nvim-web-devicons" },
+ "nvim-treesitter/nvim-treesitter",
+ "nvim-lua/plenary.nvim",
+ { "nvim-telescope/telescope.nvim", tag = "0.1.2" },
+ { "folke/trouble.nvim", dependencies = { "nvim-tree/nvim-web-devicons" } },
+})
diff --git a/lua/getchoo/plugins/lsp.lua b/lua/getchoo/plugins/lsp.lua
new file mode 100644
index 0000000..b9e8a78
--- /dev/null
+++ b/lua/getchoo/plugins/lsp.lua
@@ -0,0 +1,161 @@
+---- cmp
+local cmp = require("cmp")
+local luasnip = require("luasnip")
+local mapping = cmp.mapping
+
+require("cmp").setup({
+ completion = {
+ completeopt = "menu,menuone,noinsert",
+ },
+
+ snippet = {
+ expand = function(args)
+ luasnip.lsp_expand(args.body)
+ end,
+ },
+
+ mapping = mapping.preset.insert({
+ ["<C-n>"] = mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-p>"] = mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
+ ["<C-b>"] = mapping.scroll_docs(-4),
+ ["<C-f>"] = mapping.scroll_docs(4),
+ ["<C-Space>"] = mapping.complete(),
+ ["<C-e>"] = mapping.abort(),
+ ["<CR>"] = mapping.confirm({ select = true }),
+ ["<S-CR>"] = mapping.confirm({
+ behavior = cmp.ConfirmBehavior.Replace,
+ select = true,
+ }),
+ }),
+
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "luasnip" },
+ { name = "async_path" },
+ { name = "buffer" },
+ }),
+})
+
+---- fidget
+require("fidget").setup()
+
+---- lsp sources
+local null_ls = require("null-ls")
+local diagnostics = null_ls.builtins.diagnostics
+local formatting = null_ls.builtins.formatting
+
+local sources = {
+ lsp_servers = {
+ ["bashls"] = "bash-language-server",
+ ["clangd"] = "clangd",
+ ["pyright"] = "pyright-langserver",
+ ["rust_analyzer"] = "rust-analyzer",
+ ["tsserver"] = "typescript-language-server",
+ },
+ null_ls = {
+ diagnostics.actionlint,
+ diagnostics.alex,
+ diagnostics.codespell,
+ diagnostics.deadnix,
+ diagnostics.eslint,
+ diagnostics.pylint,
+ diagnostics.shellcheck,
+ diagnostics.statix,
+ formatting.alejandra,
+ formatting.beautysh,
+ formatting.codespell,
+ formatting.just,
+ formatting.nimpretty,
+ formatting.prettier,
+ formatting.rustfmt,
+ formatting.shellharden,
+ formatting.stylua,
+ formatting.yapf,
+ },
+}
+
+--- lsp config
+local capabilities = vim.tbl_deep_extend(
+ "force",
+ require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
+ { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } }
+)
+
+local all_config = {
+ capabilities = capabilities,
+}
+
+local servers = {}
+for server, binary in pairs(sources.lsp_servers) do
+ if vim.fn.executable(binary) == 1 then
+ servers[server] = all_config
+ end
+end
+
+servers["lua_ls"] = {
+ capabilities = capabilities,
+ settings = {
+ Lua = {
+ runtime = {
+ version = "LuaJIT",
+ },
+ diagnostics = {
+ globals = { "vim" },
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ },
+ },
+}
+
+servers["nil_ls"] = {
+ capabilities = capabilities,
+ settings = {
+ ["nil"] = {
+ nix = {
+ flake = {
+ autoArchive = false,
+ autoEvalInputs = false,
+ },
+ },
+ },
+ },
+}
+
+for server, settings in pairs(servers) do
+ require("lspconfig")[server].setup(settings)
+end
+
+---- null-ls
+-- auto-format
+local lsp_formatting = function(bufnr)
+ vim.lsp.buf.format({
+ filter = function(client)
+ return client.name == "null-ls"
+ end,
+ bufnr = bufnr,
+ })
+end
+
+local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
+local formatting_on_attach = function(client, bufnr)
+ if client.supports_method("textDocument/formatting") then
+ vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
+ vim.api.nvim_create_autocmd("BufWritePre", {
+ group = augroup,
+ buffer = bufnr,
+ callback = function()
+ lsp_formatting(bufnr)
+ end,
+ })
+ end
+end
+
+require("null-ls").setup({
+ on_attach = formatting_on_attach,
+ sources = sources.null_ls,
+})
+
+---- trouble
+require("trouble").setup()