nvim: symlink entire nvim dir from dotfiles
This commit is contained in:
parent
25dad9fdb8
commit
71616c357f
20 changed files with 662 additions and 0 deletions
1
nvim/.gitignore
vendored
Normal file
1
nvim/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
plugin/
|
17
nvim/init.lua
Normal file
17
nvim/init.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
require("thomas.plugins-setup")
|
||||
require("thomas.core.options")
|
||||
require("thomas.core.keymaps")
|
||||
require("thomas.core.colourscheme")
|
||||
require("thomas.plugins.lualine")
|
||||
require("thomas.plugins.telescope")
|
||||
require("thomas.plugins.nvim-cmp")
|
||||
require("thomas.plugins.lsp.mason")
|
||||
require("thomas.plugins.lsp.lspsaga")
|
||||
require("thomas.plugins.lsp.lspconfig")
|
||||
require("thomas.plugins.lsp.null-ls")
|
||||
require("thomas.plugins.autopairs")
|
||||
require("thomas.plugins.treesitter")
|
||||
require("thomas.plugins.gitsigns")
|
||||
require("thomas.plugins.copilot_plugin")
|
||||
require("thomas.plugins.nvim-tree")
|
||||
require("thomas.plugins.rainbow-delimiters")
|
16
nvim/lua/thomas/core/colourscheme.lua
Normal file
16
nvim/lua/thomas/core/colourscheme.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
-- set colorscheme to onedark with protected call
|
||||
-- in case it isn't installed
|
||||
local status, _ = pcall(vim.cmd, "colorscheme onedark")
|
||||
if not status then
|
||||
print("Colorscheme not found!") -- print error if colorscheme not installed
|
||||
return
|
||||
end
|
||||
|
||||
-- helper function
|
||||
local function update_hl(group, tbl)
|
||||
local old_hl = vim.api.nvim_get_hl_by_name(group, true)
|
||||
local new_hl = vim.tbl_extend("force", old_hl, tbl)
|
||||
vim.api.nvim_set_hl(0, group, new_hl)
|
||||
end
|
||||
|
||||
update_hl("Function", { bold = true })
|
34
nvim/lua/thomas/core/keymaps.lua
Normal file
34
nvim/lua/thomas/core/keymaps.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
vim.g.mapleader = ";"
|
||||
local keymap = vim.keymap
|
||||
|
||||
-- schema = keymap.set([vim mode: n (normal), i (insert)], [key sequence], [command])
|
||||
|
||||
-- Search
|
||||
keymap.set("n", "<leader>nh", ":nohl<CR>") -- clear search highlights
|
||||
|
||||
-- Windows
|
||||
keymap.set("n", "<leader>sv", "<C-w>v") -- split vertically
|
||||
keymap.set("n", "<leader>sh", "<C-w>s") -- split horizontally
|
||||
keymap.set("n", "<leader>se", "<C-w>=") -- make split window equal width
|
||||
keymap.set("n", "<leader>sx", ":close<CR>") -- close current split window
|
||||
keymap.set("n", "<leader>mm", ":MaximizerToggle<CR>") -- toggle fullscreen of current window
|
||||
|
||||
-- Navigate windows
|
||||
keymap.set("n", "<C-h>", "<C-W>h") -- move left
|
||||
keymap.set("n", "<C-j>", "<C-W>j") -- move down
|
||||
keymap.set("n", "<C-k>", "<C-W>k") -- move up
|
||||
keymap.set("n", "<C-l>", "<C-W>l") -- move left
|
||||
|
||||
-- Telescope
|
||||
keymap.set("n", "<leader>ff", "<cmd>Telescope find_files hidden=true<cr>")
|
||||
keymap.set("n", "<leader>bb", "<cmd>Telescope buffers<cr>")
|
||||
keymap.set("n", "<leader>tt", "<cmd>Telescope file_browser hidden=true<cr>")
|
||||
keymap.set("n", "<leader>gg", "<cmd>Telescope live_grep<cr>")
|
||||
keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>")
|
||||
|
||||
-- Nvim Tree
|
||||
keymap.set("n", "<leader>fb", ":NvimTreeToggle<CR>")
|
||||
|
||||
-- Git
|
||||
keymap.set("n", "<leader>lg", ":LazyGit<CR>")
|
||||
keymap.set("n", "<leader>gr", ":GV<CR>") -- Git graph view
|
26
nvim/lua/thomas/core/options.lua
Normal file
26
nvim/lua/thomas/core/options.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
vim.g.onedark_terminal_italics = 1
|
||||
|
||||
local opt = vim.opt
|
||||
opt.number = true
|
||||
opt.showmatch = true
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.hlsearch = true
|
||||
opt.incsearch = true
|
||||
opt.tabstop = 2
|
||||
opt.softtabstop = 4
|
||||
opt.shiftwidth = 4
|
||||
opt.textwidth = 100
|
||||
-- opt.clipboard = "unnamedplus"
|
||||
opt.clipboard:append("unnamedplus")
|
||||
opt.cursorline = true
|
||||
opt.background = "dark"
|
||||
opt.mouse = ""
|
||||
opt.ttyfast = true
|
||||
opt.laststatus = 2
|
||||
opt.signcolumn = "yes"
|
||||
opt.swapfile = false
|
||||
opt.showmode = false
|
||||
opt.termguicolors = true
|
||||
opt.wrap = false
|
||||
opt.backspace = "indent,eol,start"
|
122
nvim/lua/thomas/plugins-setup.lua
Normal file
122
nvim/lua/thomas/plugins-setup.lua
Normal file
|
@ -0,0 +1,122 @@
|
|||
-- auto install packer if not installed
|
||||
local ensure_packer = function()
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
|
||||
vim.cmd([[packadd packer.nvim]])
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
local packer_bootstrap = ensure_packer() -- true if packer was just installed
|
||||
|
||||
-- autocommand that reloads neovim and installs/updates/removes plugins
|
||||
-- when file is saved
|
||||
vim.cmd([[
|
||||
augroup packer_user_config
|
||||
autocmd!
|
||||
autocmd BufWritePost plugins-setup.lua source <afile> | PackerSync
|
||||
augroup end
|
||||
]])
|
||||
|
||||
-- import packer safely
|
||||
local status, packer = pcall(require, "packer")
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
-- plugins to install
|
||||
return packer.startup(function(use)
|
||||
-- packer can manage itself
|
||||
use("wbthomason/packer.nvim")
|
||||
use("joshdick/onedark.vim")
|
||||
use("junegunn/vim-easy-align")
|
||||
use("junegunn/rainbow_parentheses.vim")
|
||||
use("HiPhish/rainbow-delimiters.nvim")
|
||||
use("tpope/vim-fugitive")
|
||||
use("junegunn/gv.vim")
|
||||
use("ap/vim-css-color")
|
||||
use("wakatime/vim-wakatime")
|
||||
use("psliwka/vim-smoothie")
|
||||
use("kdheepak/lazygit.nvim")
|
||||
use("nvim-lua/plenary.nvim")
|
||||
use("szw/vim-maximizer")
|
||||
use("tpope/vim-commentary")
|
||||
use("tpope/vim-surround")
|
||||
use("vim-scripts/ReplaceWithRegister")
|
||||
use("nvim-tree/nvim-tree.lua")
|
||||
use("nvim-lualine/lualine.nvim")
|
||||
use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" })
|
||||
use({ "nvim-telescope/telescope.nvim", branch = "0.1.x" })
|
||||
use({
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
|
||||
})
|
||||
-- startup page
|
||||
use({
|
||||
"goolord/alpha-nvim",
|
||||
requires = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("alpha").setup(require("alpha.themes.startify").config)
|
||||
end,
|
||||
})
|
||||
|
||||
-- autocompletion and snippets
|
||||
use("hrsh7th/nvim-cmp") -- completion plugin
|
||||
use("hrsh7th/cmp-buffer") -- source for text in buffer
|
||||
use("hrsh7th/cmp-path") -- source for file system paths
|
||||
use("L3MON4D3/LuaSnip") -- snippet engine
|
||||
use("saadparwaiz1/cmp_luasnip") -- for autocompletion
|
||||
use("rafamadriz/friendly-snippets") -- useful snippets
|
||||
|
||||
-- managing & installing lsp servers, linters & formatters
|
||||
use("williamboman/mason.nvim") -- in charge of managing lsp servers, linters & formatters
|
||||
use("williamboman/mason-lspconfig.nvim") -- bridges gap b/w mason & lspconfig
|
||||
|
||||
-- configuring lsp servers
|
||||
use("neovim/nvim-lspconfig") -- easily configure language servers
|
||||
use("hrsh7th/cmp-nvim-lsp") -- for autocompletion
|
||||
use({ "glepnir/lspsaga.nvim", branch = "main" })
|
||||
|
||||
use("jose-elias-alvarez/typescript.nvim") -- additional functionality for typescript server (e.g. rename file & update imports)
|
||||
use("onsails/lspkind.nvim") -- vs-code like icons for autocompletion
|
||||
|
||||
-- formatting and linting
|
||||
use("jose-elias-alvarez/null-ls.nvim") -- configure formatters & linters
|
||||
use("jayp0521/mason-null-ls.nvim") -- bridges gap b/w mason & null-ls
|
||||
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
run = ":TSUpdate",
|
||||
})
|
||||
|
||||
-- auto closing
|
||||
use("windwp/nvim-autopairs") -- autoclose parens, brackets, quotes, etc...
|
||||
use({ "windwp/nvim-ts-autotag", after = "nvim-treesitter" }) -- autoclose tags
|
||||
|
||||
-- git integration
|
||||
use("lewis6991/gitsigns.nvim") -- show line modifications on left hand side
|
||||
|
||||
-- GitHub Copilot
|
||||
|
||||
use({
|
||||
"zbirenbaum/copilot.lua",
|
||||
cmd = "Copilot",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
require("copilot").setup({})
|
||||
end,
|
||||
})
|
||||
|
||||
use({
|
||||
"zbirenbaum/copilot-cmp",
|
||||
after = { "copilot.lua" },
|
||||
config = function()
|
||||
require("copilot_cmp").setup()
|
||||
end,
|
||||
})
|
||||
if packer_bootstrap then
|
||||
require("packer").sync()
|
||||
end
|
||||
end)
|
29
nvim/lua/thomas/plugins/autopairs.lua
Normal file
29
nvim/lua/thomas/plugins/autopairs.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
-- import nvim-autopairs safely
|
||||
local autopairs_setup, autopairs = pcall(require, "nvim-autopairs")
|
||||
if not autopairs_setup then
|
||||
return
|
||||
end
|
||||
|
||||
-- configure autopairs
|
||||
autopairs.setup({
|
||||
check_ts = true, -- enable treesitter
|
||||
ts_config = {
|
||||
lua = { "string" }, -- don't add pairs in lua string treesitter nodes
|
||||
javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes
|
||||
},
|
||||
})
|
||||
|
||||
-- import nvim-autopairs completion functionality safely
|
||||
local cmp_autopairs_setup, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp")
|
||||
if not cmp_autopairs_setup then
|
||||
return
|
||||
end
|
||||
|
||||
-- import nvim-cmp plugin safely (completions plugin)
|
||||
local cmp_setup, cmp = pcall(require, "cmp")
|
||||
if not cmp_setup then
|
||||
return
|
||||
end
|
||||
|
||||
-- make autopairs and completion work together
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
17
nvim/lua/thomas/plugins/copilot_plugin.lua
Normal file
17
nvim/lua/thomas/plugins/copilot_plugin.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
local status, copilot = pcall(require, "copilot")
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
copilot.setup({
|
||||
suggestion = {
|
||||
enabled = false,
|
||||
},
|
||||
panel = {
|
||||
enabled = false,
|
||||
},
|
||||
filetypes = {
|
||||
yaml = false,
|
||||
markdown = false,
|
||||
},
|
||||
})
|
8
nvim/lua/thomas/plugins/gitsigns.lua
Normal file
8
nvim/lua/thomas/plugins/gitsigns.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
-- import gitsigns plugin safely
|
||||
local setup, gitsigns = pcall(require, "gitsigns")
|
||||
if not setup then
|
||||
return
|
||||
end
|
||||
|
||||
-- configure/enable gitsigns
|
||||
gitsigns.setup()
|
81
nvim/lua/thomas/plugins/lsp/lspconfig.lua
Normal file
81
nvim/lua/thomas/plugins/lsp/lspconfig.lua
Normal file
|
@ -0,0 +1,81 @@
|
|||
-- import lspconfig plugin safely
|
||||
local lspconfig_status, lspconfig = pcall(require, "lspconfig")
|
||||
if not lspconfig_status then
|
||||
return
|
||||
end
|
||||
|
||||
-- import cmp-nvim-lsp plugin safely
|
||||
local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||
if not cmp_nvim_lsp_status then
|
||||
return
|
||||
end
|
||||
|
||||
-- import typescript plugin safely
|
||||
local typescript_setup, typescript = pcall(require, "typescript")
|
||||
if not typescript_setup then
|
||||
return
|
||||
end
|
||||
|
||||
local keymap = vim.keymap
|
||||
|
||||
-- enable keybinds only for when lsp server available
|
||||
local on_attach = function(client, bufnr)
|
||||
-- keybind options
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
|
||||
-- set keybinds
|
||||
keymap.set("n", "gf", "<cmd>Lspsaga lsp_finder<CR>", opts) -- show definition
|
||||
keymap.set("n", "gd", "<cmd>Lspsaga peek_definition<CR>", opts) -- see definition and make edits in window
|
||||
keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) -- go to implementation
|
||||
keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts) -- see available code actions
|
||||
keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename
|
||||
keymap.set("n", "<leader>b", "<cmd>Lspsaga show_line_diagnostics<CR>", opts) -- show diagnostics for line
|
||||
keymap.set("n", "<leader>d", "<cmd>Lspsaga show_cursor_diagnostics<CR>", opts) -- show diagnostics for cursor
|
||||
keymap.set("n", "<leader>y", "<cmd>Lspsaga finder<CR>", opts) -- find refs elsewhere in project
|
||||
end
|
||||
-- used to enable autocompletion (assign to every lsp server config)
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
|
||||
-- Change the Diagnostic symbols in the sign column (gutter)
|
||||
local signs = { Error = " ", Warn = " ", Hint = "ﴞ ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
||||
|
||||
-- Hide diagnostic virtual text by default, but toggle visibility with `lead:lh` command
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>lh", function()
|
||||
local config = vim.diagnostic.config()
|
||||
vim.diagnostic.config({ virtual_text = not config.virtual_text })
|
||||
print("Toggling LSP diagnostics")
|
||||
end)
|
||||
|
||||
-- configure html server
|
||||
lspconfig["html"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
|
||||
-- configure typescript server with plugin
|
||||
typescript.setup({
|
||||
server = {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
},
|
||||
})
|
||||
|
||||
-- configure css server
|
||||
lspconfig["cssls"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
|
||||
-- configure tailwindcss server
|
||||
lspconfig["tailwindcss"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
19
nvim/lua/thomas/plugins/lsp/lspsaga.lua
Normal file
19
nvim/lua/thomas/plugins/lsp/lspsaga.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
-- import lspsaga safely
|
||||
local saga_status, saga = pcall(require, "lspsaga")
|
||||
if not saga_status then
|
||||
return
|
||||
end
|
||||
|
||||
saga.setup({
|
||||
-- keybinds for navigation in lspsaga window
|
||||
scroll_preview = { scroll_down = "<C-f>", scroll_up = "<C-b>" },
|
||||
-- use enter to open file with definition preview
|
||||
definition = {
|
||||
edit = "<CR>",
|
||||
},
|
||||
ui = {
|
||||
colors = {
|
||||
normal_bg = "#022746",
|
||||
},
|
||||
},
|
||||
})
|
51
nvim/lua/thomas/plugins/lsp/mason.lua
Normal file
51
nvim/lua/thomas/plugins/lsp/mason.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
-- import mason plugin safely
|
||||
local mason_status, mason = pcall(require, "mason")
|
||||
if not mason_status then
|
||||
return
|
||||
end
|
||||
|
||||
-- import mason-lspconfig plugin safely
|
||||
local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig")
|
||||
if not mason_lspconfig_status then
|
||||
return
|
||||
end
|
||||
|
||||
-- import mason-null-ls plugin safely
|
||||
local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls")
|
||||
if not mason_null_ls_status then
|
||||
return
|
||||
end
|
||||
|
||||
mason.setup()
|
||||
|
||||
mason_lspconfig.setup({
|
||||
-- list of servers for mason to install
|
||||
ensure_installed = {
|
||||
"tsserver",
|
||||
"html",
|
||||
"cssls",
|
||||
"bashls",
|
||||
"dockerls",
|
||||
"eslint",
|
||||
"pyre",
|
||||
"tailwindcss",
|
||||
"lua_ls",
|
||||
"jsonls",
|
||||
"yamlls",
|
||||
},
|
||||
-- auto-install configured servers (with lspconfig)
|
||||
automatic_installation = true, -- not the same as ensure_installed
|
||||
})
|
||||
|
||||
mason_null_ls.setup({
|
||||
-- list of formatters & linters for mason to install
|
||||
ensure_installed = {
|
||||
"prettier", -- ts/js formatter
|
||||
"stylua", -- lua formatter
|
||||
"eslint_d", -- ts/js linter
|
||||
"black",
|
||||
"pylint",
|
||||
},
|
||||
|
||||
automatic_installation = true,
|
||||
})
|
49
nvim/lua/thomas/plugins/lsp/null-ls.lua
Normal file
49
nvim/lua/thomas/plugins/lsp/null-ls.lua
Normal file
|
@ -0,0 +1,49 @@
|
|||
-- import null-ls plugin safely
|
||||
local setup, null_ls = pcall(require, "null-ls")
|
||||
|
||||
if not setup then
|
||||
return
|
||||
end
|
||||
|
||||
-- for conciseness
|
||||
local formatting = null_ls.builtins.formatting -- to setup formatters
|
||||
local diagnostics = null_ls.builtins.diagnostics -- to setup linters
|
||||
|
||||
-- to setup format on save
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
formatting.prettier.with({
|
||||
extra_filetypes = { "markdown", "md" },
|
||||
}), -- js/ts formatter
|
||||
formatting.stylua, -- lua formatter
|
||||
formatting.black,
|
||||
diagnostics.ruff,
|
||||
-- diagnostics.pylint,
|
||||
diagnostics.eslint_d.with({ -- js/ts linter
|
||||
condition = function(utils)
|
||||
return utils.root_has_file(".eslintrc.js") -- change file extension if you use something else
|
||||
end,
|
||||
}),
|
||||
},
|
||||
-- configure format on save
|
||||
on_attach = function(current_client, bufnr)
|
||||
if current_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()
|
||||
vim.lsp.buf.format({
|
||||
filter = function(client)
|
||||
-- only use null-ls for formatting instead of lsp server
|
||||
return client.name == "null-ls"
|
||||
end,
|
||||
bufnr = bufnr,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
33
nvim/lua/thomas/plugins/lualine.lua
Normal file
33
nvim/lua/thomas/plugins/lualine.lua
Normal file
|
@ -0,0 +1,33 @@
|
|||
local status, lualine = pcall(require, "lualine")
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
local lualine_onedark = require("lualine.themes.onedark")
|
||||
|
||||
-- lualine_onedark.normal.c.bg = "#3c3836"
|
||||
|
||||
lualine.setup({
|
||||
options = {
|
||||
theme = lualine_onedark,
|
||||
component_separators = { left = "|", right = "|" },
|
||||
section_separators = { left = " ", right = " " },
|
||||
},
|
||||
sections = {
|
||||
lualine_c = {
|
||||
{
|
||||
"buffers",
|
||||
show_filename_only = true,
|
||||
show_modified_status = true,
|
||||
mode = 3,
|
||||
filetype_names = {
|
||||
TelescopePrompt = "Telescope",
|
||||
},
|
||||
},
|
||||
{
|
||||
"filename",
|
||||
path = 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
56
nvim/lua/thomas/plugins/nvim-cmp.lua
Normal file
56
nvim/lua/thomas/plugins/nvim-cmp.lua
Normal file
|
@ -0,0 +1,56 @@
|
|||
-- import nvim-cmp plugin safely
|
||||
local cmp_status, cmp = pcall(require, "cmp")
|
||||
if not cmp_status then
|
||||
return
|
||||
end
|
||||
|
||||
-- import luasnip plugin safely
|
||||
local luasnip_status, luasnip = pcall(require, "luasnip")
|
||||
if not luasnip_status then
|
||||
return
|
||||
end
|
||||
|
||||
-- import lspkind plugin safely
|
||||
local lspkind_status, lspkind = pcall(require, "lspkind")
|
||||
if not lspkind_status then
|
||||
return
|
||||
end
|
||||
|
||||
-- load vs-code like snippets from plugins (e.g. friendly-snippets)
|
||||
require("luasnip/loaders/from_vscode").lazy_load()
|
||||
|
||||
vim.opt.completeopt = "menu,menuone,noselect"
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
|
||||
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||
}),
|
||||
-- sources for autocompletion
|
||||
sources = cmp.config.sources({
|
||||
{ name = "copilot", group_index = 2 },
|
||||
{ name = "nvim_lsp" }, -- lsp
|
||||
{ name = "luasnip" }, -- snippets
|
||||
{ name = "buffer" }, -- text within current buffer
|
||||
{ name = "path" }, -- file system paths
|
||||
}),
|
||||
|
||||
-- configure lspkind for vs-code like icons
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
maxwidth = 150,
|
||||
ellipsis_char = "...",
|
||||
symbol_map = { Copilot = "" },
|
||||
}),
|
||||
},
|
||||
})
|
17
nvim/lua/thomas/plugins/nvim-tree.lua
Normal file
17
nvim/lua/thomas/plugins/nvim-tree.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
local setup, nvimtree = pcall(require, "nvim-tree")
|
||||
if not setup then
|
||||
return
|
||||
end
|
||||
|
||||
vim.g.loaded = 1
|
||||
vim.g.loaded_netrw = 1
|
||||
|
||||
nvimtree.setup({
|
||||
actions = {
|
||||
open_file = {
|
||||
window_picker = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
20
nvim/lua/thomas/plugins/rainbow-delimiters.lua
Normal file
20
nvim/lua/thomas/plugins/rainbow-delimiters.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
-- import rainbow-delimeters safely
|
||||
local setup, rd = pcall(require, "rainbow-delimiters.setup")
|
||||
if not setup then
|
||||
return
|
||||
end
|
||||
|
||||
rd.setup({
|
||||
-- change the default colour order
|
||||
-- only use three colours, to match One Dark theme in VSCode
|
||||
highlight = {
|
||||
"RainbowDelimiterYellow",
|
||||
"RainbowDelimiterViolet",
|
||||
"RainbowDelimiterCyan",
|
||||
},
|
||||
})
|
||||
|
||||
-- change colour values to match One Dark
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterViolet", { foreground = "#C678DD", bold = true })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterYellow", { foreground = "#E5C07B", bold = true })
|
||||
vim.api.nvim_set_hl(0, "RainbowDelimiterCyan", { foreground = "#56B6C2", bold = true })
|
27
nvim/lua/thomas/plugins/telescope.lua
Normal file
27
nvim/lua/thomas/plugins/telescope.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
local telescope_setup, telescope = pcall(require, "telescope")
|
||||
if not telescope_setup then
|
||||
return
|
||||
end
|
||||
|
||||
local actions_setup, actions = pcall(require, "telescope.actions")
|
||||
if not actions_setup then
|
||||
return
|
||||
end
|
||||
|
||||
telescope.load_extension("fzf")
|
||||
telescope.load_extension("file_browser")
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-k>"] = actions.move_selection_previous, -- move to prev result
|
||||
["<C-j>"] = actions.move_selection_next, -- move to next result
|
||||
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist, -- send selected to quickfixlist
|
||||
},
|
||||
},
|
||||
file_ignore_patterns = {
|
||||
"node_modules",
|
||||
".git",
|
||||
},
|
||||
},
|
||||
})
|
39
nvim/lua/thomas/plugins/treesitter.lua
Normal file
39
nvim/lua/thomas/plugins/treesitter.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
-- import nvim-treesitter plugin safely
|
||||
local status, treesitter = pcall(require, "nvim-treesitter.configs")
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
-- configure treesitter
|
||||
treesitter.setup({
|
||||
-- enable syntax highlighting
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
-- enable indentation
|
||||
indent = { enable = true },
|
||||
-- enable autotagging (w/ nvim-ts-autotag plugin)
|
||||
autotag = { enable = true },
|
||||
-- ensure these language parsers are installed
|
||||
ensure_installed = {
|
||||
"json",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"tsx",
|
||||
"yaml",
|
||||
"html",
|
||||
"css",
|
||||
"scss",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"graphql",
|
||||
"bash",
|
||||
"lua",
|
||||
"vim",
|
||||
"dockerfile",
|
||||
"gitignore",
|
||||
"python",
|
||||
},
|
||||
-- auto install above language parsers
|
||||
auto_install = true,
|
||||
})
|
Loading…
Add table
Reference in a new issue