From 140623d2797f79ab4aecbb4db349207127ff09bc Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sun, 1 Jan 2023 14:42:32 -0500 Subject: Full blown rewrite of my Neovim configuration --- after/plugin/lsp.lua | 101 ++++++++++++++++++++++++++++++++++++++++++++ after/plugin/nord.lua | 9 ++++ after/plugin/nvim-tree.lua | 24 +++++++++++ after/plugin/treesitter.lua | 33 +++++++++++++++ after/plugin/undotree.lua | 1 + 5 files changed, 168 insertions(+) create mode 100644 after/plugin/lsp.lua create mode 100644 after/plugin/nord.lua create mode 100644 after/plugin/nvim-tree.lua create mode 100644 after/plugin/treesitter.lua create mode 100644 after/plugin/undotree.lua (limited to 'after/plugin') diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..8056dfa --- /dev/null +++ b/after/plugin/lsp.lua @@ -0,0 +1,101 @@ +local lsp = require("lsp-zero") + +lsp.preset("recommended") + +lsp.ensure_installed({ + 'tsserver', + 'eslint', + 'sumneko_lua', + 'rust_analyzer', + 'gopls', + 'clangd', +}) + +-- Fix Undefined global 'vim' +lsp.configure('sumneko_lua', { + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + } + } + } +}) + + +local cmp = require('cmp') +local cmp_select = {behavior = cmp.SelectBehavior.Select} +local cmp_mappings = lsp.defaults.cmp_mappings({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), +}) + +-- disable completion with tab +-- this helps with copilot setup +cmp_mappings[''] = nil +cmp_mappings[''] = nil + +lsp.setup_nvim_cmp({ + mapping = cmp_mappings +}) + +lsp.set_preferences({ + suggest_lsp_servers = false, + sign_icons = { + error = 'E', + warn = 'W', + hint = 'H', + info = 'I' + } +}) + +lsp.on_attach(function(client, bufnr) + local opts = {buffer = bufnr, remap = false} + + if client.name == "eslint" then + vim.cmd.LspStop('eslint') + return + end + + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + -- goto defintion + -- vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + -- hover docs + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + + nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + nmap("gr", vim.lsp.buf.references, '[G]oto [R]eferences') + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + + nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + + + -- vim.keymap.set("n", "vws", vim.lsp.buf.workspace_symbol, opts) + -- vim.keymap.set("n", "vd", vim.diagnostic.open_float, opts) + -- vim.keymap.set("n", "[d", vim.diagnostic.goto_next, opts) + -- vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, opts) + -- vim.keymap.set("n", "vca", vim.lsp.buf.code_action, opts) + -- vim.keymap.set("n", "vrn", vim.lsp.buf.rename, opts) + -- vim.keymap.set("i", "", vim.lsp.buf.signature_help, opts) +end) + +lsp.setup() + +vim.diagnostic.config({ + virtual_text = true, +}) + diff --git a/after/plugin/nord.lua b/after/plugin/nord.lua new file mode 100644 index 0000000..5181b47 --- /dev/null +++ b/after/plugin/nord.lua @@ -0,0 +1,9 @@ +-- vim.g.nord_contrast = true +-- vim.g.nord_borders = false +vim.g.nord_disable_background = true +vim.g.nord_italic = false +-- vim.g.nord_uniform_diff_background = true +vim.g.nord_bold = false + +-- Load the colorscheme +require('nord').set() diff --git a/after/plugin/nvim-tree.lua b/after/plugin/nvim-tree.lua new file mode 100644 index 0000000..d89c294 --- /dev/null +++ b/after/plugin/nvim-tree.lua @@ -0,0 +1,24 @@ +-- set termguicolors to enable highlight groups +vim.opt.termguicolors = true + +-- empty setup using defaults +require("nvim-tree").setup() + +-- OR setup with some options +require("nvim-tree").setup({ + sort_by = "case_sensitive", + view = { + adaptive_size = true, + mappings = { + list = { + { key = "u", action = "dir_up" }, + }, + }, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = true, + }, +}) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..2c0ff58 --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,33 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" + -- https://github.com/nvim-treesitter/nvim-treesitter + ensure_installed = { + "c", "lua", "rust", 'javascript', 'typescript', 'go', 'hcl', + 'java', 'lua', 'make', 'perl', 'python', 'scheme', 'sql', 'svelte', + 'terraform', 'yaml', 'bash', 'css', 'haskell', + }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + -- List of parsers to ignore installing (for "all") + -- ignore_install = { "javascript" }, + + ---- 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")! + + highlight = { + -- `false` will disable the whole extension + enable = true, + + -- 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). + -- 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 + -- additional_vim_regex_highlighting = false, + }, +} diff --git a/after/plugin/undotree.lua b/after/plugin/undotree.lua new file mode 100644 index 0000000..785e017 --- /dev/null +++ b/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set('n', "u", vim.cmd.UndotreeToggle) -- cgit v1.2.3