Skip to content

Instantly share code, notes, and snippets.

@lmiller1990
Last active September 15, 2024 11:33
Show Gist options
  • Save lmiller1990/dd8df1d047f59a938a8ecd9877dbff84 to your computer and use it in GitHub Desktop.
Save lmiller1990/dd8df1d047f59a938a8ecd9877dbff84 to your computer and use it in GitHub Desktop.
Neovim
vim.cmd("set expandtab")
vim.cmd("set number")
vim.cmd("set tabstop=2")
vim.cmd("set shiftwidth=2")
vim.cmd("set expandtab")
vim.g.mapleader = " "
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
local plugins = {
-- init.lua:
{
"nvim-telescope/telescope.nvim",
tag = "0.1.8",
-- or , branch = '0.1.x',
dependencies = { "nvim-lua/plenary.nvim" },
},
-- plugins/telescope.lua:
{
"nvim-telescope/telescope.nvim",
tag = "0.1.8",
-- or , branch = '0.1.x',
dependencies = { "nvim-lua/plenary.nvim" },
},
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
},
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
},
},
{
"williamboman/mason.nvim",
},
{
"williamboman/mason-lspconfig.nvim",
},
{
"neovim/nvim-lspconfig",
},
{
"nvimtools/none-ls.nvim",
},
{
"hrsh7th/cmp-nvim-lsp",
},
{
"hrsh7th/nvim-cmp",
},
{
"L3MON4D3/LuaSnip",
},
dependencies = { "saadparwaiz1/cmp_luasnip", "rafamadriz/friendly-snippets" },
{
"catppuccin/nvim",
},
}
require("lazy").setup({
spec = {
-- add your plugins here
plugins,
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
-- install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
-- checker = { enabled = true },
})
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<C-p>", builtin.find_files, {})
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
require("lazy").setup({})
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = { "lua", "python", "javascript", "typescript", "json" },
highlight = { enable = true },
indent = { enable = true },
})
require("mason").setup({})
require("mason-lspconfig").setup({
ensure_installed = { "lua_ls", "pyright", "ts_ls" },
})
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
vim.keymap.set({ "n", "v" }, "<space>ca", vim.lsp.buf.code_action, {})
vim.keymap.set("n", "<C-n>", ":Neotree filesystem toggle left<CR>")
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.prettier.with({
filetypes = {
"typescript",
"vue",
},
}),
},
})
vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
command = "setlocal shiftwidth=2 tabstop=2",
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "py",
command = "setlocal shiftwidth=2 tabstop=2",
})
-- completions
--
local cmp = require("cmp")
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
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 = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" }, -- For luasnip users.
}, {
{ name = "buffer" },
}),
})
require("luasnip.loaders.from_vscode").lazy_load()
local capabilities = require("cmp_nvim_lsp").default_capabilities()
require("lspconfig").pyright.setup({
capabilities = capabilities,
})
require("lspconfig").lua_ls.setup({
capabilities = capabilities,
})
require("lspconfig").ts_ls.setup({
capabilities = capabilities,
})
vim.api.nvim_set_keymap("n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>", {})
-- setup must be called before loading
vim.cmd("colorscheme catppuccin")
require("catppuccin").setup({
flavour = "frappe", -- latte, frappe, macchiato, mocha
background = { -- :h background
light = "latte",
dark = "frappe",
},
})
{
"Ansi 5 Color" : {
"Red Component" : 0.82745098039215681,
"Color Space" : "sRGB",
"Blue Component" : 0.50980392156862742,
"Green Component" : 0.21176470588235294
},
"Tags" : [
],
"Ansi 12 Color" : {
"Red Component" : 0.51372549019607838,
"Color Space" : "sRGB",
"Blue Component" : 0.58823529411764708,
"Green Component" : 0.58039215686274515
},
"Use Non-ASCII Font" : false,
"Ansi 6 Color" : {
"Red Component" : 0.16470588235294117,
"Color Space" : "sRGB",
"Blue Component" : 0.59607843137254901,
"Green Component" : 0.63137254901960782
},
"Bold Color" : {
"Red Component" : 0.57647058823529407,
"Color Space" : "sRGB",
"Blue Component" : 0.63137254901960782,
"Green Component" : 0.63137254901960782
},
"Normal Font" : "CodeNewRomanNFP 18",
"Ansi 0 Color" : {
"Red Component" : 0.027450980392156862,
"Color Space" : "sRGB",
"Blue Component" : 0.25882352941176473,
"Green Component" : 0.21176470588235294
},
"Ansi 3 Color" : {
"Red Component" : 0.70980392156862748,
"Color Space" : "sRGB",
"Blue Component" : 0,
"Green Component" : 0.53725490196078429
},
"Rows" : 25,
"Default Bookmark" : "No",
"Custom Directory" : "Recycle",
"Cursor Guide Color" : {
"Red Component" : 0.70214027166366577,
"Color Space" : "sRGB",
"Blue Component" : 1,
"Alpha Component" : 0.25,
"Green Component" : 0.92681378126144409
},
"Non-ASCII Anti Aliased" : true,
"Use Bright Bold" : true,
"Ansi 10 Color" : {
"Red Component" : 0.34509803921568627,
"Color Space" : "sRGB",
"Blue Component" : 0.45882352941176469,
"Green Component" : 0.43137254901960786
},
"Ambiguous Double Width" : false,
"Jobs to Ignore" : [
"rlogin",
"ssh",
"slogin",
"telnet"
],
"Ansi 15 Color" : {
"Red Component" : 0.99215686274509807,
"Color Space" : "sRGB",
"Blue Component" : 0.8901960784313725,
"Green Component" : 0.96470588235294119
},
"Foreground Color" : {
"Red Component" : 0.51372549019607838,
"Color Space" : "sRGB",
"Blue Component" : 0.58823529411764708,
"Green Component" : 0.58039215686274515
},
"Bound Hosts" : [
],
"Working Directory" : "\/Users\/lachlanmiller",
"Blinking Cursor" : false,
"Disable Window Resizing" : true,
"Sync Title" : false,
"Prompt Before Closing 2" : false,
"BM Growl" : true,
"Command" : "",
"Description" : "Default",
"Smart Cursor Color" : false,
"Mouse Reporting" : false,
"Screen" : -1,
"Selection Color" : {
"Red Component" : 0.027450980392156862,
"Color Space" : "sRGB",
"Blue Component" : 0.25882352941176473,
"Green Component" : 0.21176470588235294
},
"Columns" : 80,
"Idle Code" : 0,
"Ansi 13 Color" : {
"Red Component" : 0.42352941176470588,
"Color Space" : "sRGB",
"Blue Component" : 0.7686274509803922,
"Green Component" : 0.44313725490196076
},
"Title Components" : 2,
"Custom Command" : "No",
"ASCII Anti Aliased" : true,
"Non Ascii Font" : "Monaco 12",
"Vertical Spacing" : 1,
"Use Bold Font" : true,
"Option Key Sends" : 0,
"Selected Text Color" : {
"Red Component" : 0.57647058823529407,
"Color Space" : "sRGB",
"Blue Component" : 0.63137254901960782,
"Green Component" : 0.63137254901960782
},
"Background Color" : {
"Red Component" : 0.11764705882352941,
"Color Space" : "sRGB",
"Blue Component" : 0.1803921568627451,
"Alpha Component" : 1,
"Green Component" : 0.11764705882352941
},
"Character Encoding" : 4,
"Ansi 11 Color" : {
"Red Component" : 0.396078431372549,
"Color Space" : "sRGB",
"Blue Component" : 0.51372549019607838,
"Green Component" : 0.4823529411764706
},
"Use Italic Font" : true,
"Unlimited Scrollback" : true,
"Keyboard Map" : {
"0xf700-0x260000" : {
"Text" : "[1;6A",
"Action" : 10
},
"0x37-0x40000" : {
"Text" : "0x1f",
"Action" : 11
},
"0x32-0x40000" : {
"Text" : "0x00",
"Action" : 11
},
"0xf709-0x20000" : {
"Text" : "[17;2~",
"Action" : 10
},
"0xf70c-0x20000" : {
"Text" : "[20;2~",
"Action" : 10
},
"0xf729-0x20000" : {
"Text" : "[1;2H",
"Action" : 10
},
"0xf72b-0x40000" : {
"Text" : "[1;5F",
"Action" : 10
},
"0xf705-0x20000" : {
"Text" : "[1;2Q",
"Action" : 10
},
"0xf703-0x260000" : {
"Text" : "[1;6C",
"Action" : 10
},
"0xf700-0x220000" : {
"Text" : "[1;2A",
"Action" : 10
},
"0xf701-0x280000" : {
"Text" : "0x1b 0x1b 0x5b 0x42",
"Action" : 11
},
"0x38-0x40000" : {
"Text" : "0x7f",
"Action" : 11
},
"0x33-0x40000" : {
"Text" : "0x1b",
"Action" : 11
},
"0xf703-0x220000" : {
"Text" : "[1;2C",
"Action" : 10
},
"0xf701-0x240000" : {
"Text" : "[1;5B",
"Action" : 10
},
"0xf70d-0x20000" : {
"Text" : "[21;2~",
"Action" : 10
},
"0xf702-0x260000" : {
"Text" : "[1;6D",
"Action" : 10
},
"0xf729-0x40000" : {
"Text" : "[1;5H",
"Action" : 10
},
"0xf706-0x20000" : {
"Text" : "[1;2R",
"Action" : 10
},
"0x34-0x40000" : {
"Text" : "0x1c",
"Action" : 11
},
"0xf700-0x280000" : {
"Text" : "0x1b 0x1b 0x5b 0x41",
"Action" : 11
},
"0x2d-0x40000" : {
"Text" : "0x1f",
"Action" : 11
},
"0xf70e-0x20000" : {
"Text" : "[23;2~",
"Action" : 10
},
"0xf702-0x220000" : {
"Text" : "[1;2D",
"Action" : 10
},
"0xf703-0x280000" : {
"Text" : "0x1b 0x1b 0x5b 0x43",
"Action" : 11
},
"0xf700-0x240000" : {
"Text" : "[1;5A",
"Action" : 10
},
"0xf707-0x20000" : {
"Text" : "[1;2S",
"Action" : 10
},
"0xf70a-0x20000" : {
"Text" : "[18;2~",
"Action" : 10
},
"0x35-0x40000" : {
"Text" : "0x1d",
"Action" : 11
},
"0xf70f-0x20000" : {
"Text" : "[24;2~",
"Action" : 10
},
"0xf703-0x240000" : {
"Text" : "[1;5C",
"Action" : 10
},
"0xf701-0x260000" : {
"Text" : "[1;6B",
"Action" : 10
},
"0xf702-0x280000" : {
"Text" : "0x1b 0x1b 0x5b 0x44",
"Action" : 11
},
"0xf72b-0x20000" : {
"Text" : "[1;2F",
"Action" : 10
},
"0x36-0x40000" : {
"Text" : "0x1e",
"Action" : 11
},
"0xf708-0x20000" : {
"Text" : "[15;2~",
"Action" : 10
},
"0xf701-0x220000" : {
"Text" : "[1;2B",
"Action" : 10
},
"0xf70b-0x20000" : {
"Text" : "[19;2~",
"Action" : 10
},
"0xf702-0x240000" : {
"Text" : "[1;5D",
"Action" : 10
},
"0xf704-0x20000" : {
"Text" : "[1;2P",
"Action" : 10
}
},
"Window Type" : 0,
"Cursor Boost" : 0,
"Background Image Location" : "",
"Blur" : false,
"Badge Color" : {
"Red Component" : 1,
"Color Space" : "sRGB",
"Blue Component" : 0,
"Alpha Component" : 0.5,
"Green Component" : 0.14910030364990234
},
"Scrollback Lines" : 0,
"Send Code When Idle" : false,
"Close Sessions On End" : true,
"Terminal Type" : "xterm-256color",
"Visual Bell" : true,
"Flashing Bell" : false,
"Silence Bell" : true,
"Ansi 14 Color" : {
"Red Component" : 0.57647058823529407,
"Color Space" : "sRGB",
"Blue Component" : 0.63137254901960782,
"Green Component" : 0.63137254901960782
},
"Name" : "Dark",
"Cursor Text Color" : {
"Red Component" : 0.027450980392156862,
"Color Space" : "sRGB",
"Blue Component" : 0.25882352941176473,
"Green Component" : 0.21176470588235294
},
"Shortcut" : "",
"Cursor Color" : {
"Red Component" : 0.51372549019607838,
"Color Space" : "sRGB",
"Blue Component" : 0.58823529411764708,
"Green Component" : 0.58039215686274515
},
"Transparency" : 0,
"Guid" : "43599A13-C7BD-41C0-9B02-AB44C2159CE0",
"Ansi 1 Color" : {
"Red Component" : 0.86274509803921573,
"Color Space" : "sRGB",
"Blue Component" : 0.18431372549019609,
"Green Component" : 0.19607843137254902
},
"Link Color" : {
"Red Component" : 0,
"Color Space" : "sRGB",
"Blue Component" : 0.73422706127166748,
"Alpha Component" : 1,
"Green Component" : 0.35915294289588928
},
"Ansi 2 Color" : {
"Red Component" : 0.52156862745098043,
"Color Space" : "sRGB",
"Blue Component" : 0,
"Green Component" : 0.59999999999999998
},
"Right Option Key Sends" : 0,
"Has Hotkey" : false,
"Ansi 7 Color" : {
"Red Component" : 0.93333333333333335,
"Color Space" : "sRGB",
"Blue Component" : 0.83529411764705885,
"Green Component" : 0.90980392156862744
},
"Ansi 8 Color" : {
"Red Component" : 0,
"Color Space" : "sRGB",
"Blue Component" : 0.21176470588235294,
"Green Component" : 0.16862745098039217
},
"Ansi 9 Color" : {
"Red Component" : 0.79607843137254897,
"Color Space" : "sRGB",
"Blue Component" : 0.086274509803921567,
"Green Component" : 0.29411764705882354
},
"Horizontal Spacing" : 1,
"Ansi 4 Color" : {
"Red Component" : 0.14901960784313725,
"Color Space" : "sRGB",
"Blue Component" : 0.82352941176470584,
"Green Component" : 0.54509803921568623
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment