diff options
author | Matthew Wozniak <sirtomato999@gmail.com> | 2023-12-29 19:39:37 -0500 |
---|---|---|
committer | Matthew Wozniak <sirtomato999@gmail.com> | 2023-12-29 19:39:37 -0500 |
commit | 047ea7318b352692b0c2cb49590d75ea1588c148 (patch) | |
tree | 069acb3e7045025f4b6ace8752617251d4ca0a2b /after/plugin | |
parent | 256937593ad354a82c520b3c0968f0bb17e86768 (diff) | |
download | nvim-047ea7318b352692b0c2cb49590d75ea1588c148.tar.gz nvim-047ea7318b352692b0c2cb49590d75ea1588c148.zip |
new config
Diffstat (limited to 'after/plugin')
-rw-r--r-- | after/plugin/colors.lua | 9 | ||||
-rw-r--r-- | after/plugin/lsp.lua | 120 | ||||
-rw-r--r-- | after/plugin/telescope.lua | 6 | ||||
-rw-r--r-- | after/plugin/treesitter.lua | 21 |
4 files changed, 74 insertions, 82 deletions
diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua deleted file mode 100644 index 7c7bd0f..0000000 --- a/after/plugin/colors.lua +++ /dev/null @@ -1,9 +0,0 @@ -function ColorMyPencils(color) - color = color or 'wal' - vim.cmd.colorscheme(color) - vim.api.nvim_set_hl(0, "Normal", { bg = 'none'}) - vim.api.nvim_set_hl(0, "NormalFloat", { bg = 'none'}) - vim.api.nvim_set_hl(0, "EndOfBuffer", { bg = 'none'}) -end - -ColorMyPencils() diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index cfb10e8..7722c1e 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -1,59 +1,81 @@ -local lsp = require("lsp-zero") +-- Setup autocomplete/LSP clients +local lspconfig = require('lspconfig') +local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities() -lsp.preset("recommended") +local servers = {"clangd", "zls", "rust_analyzer", "lua_ls"} + for _, lsp in pairs(servers) do + lspconfig[lsp].setup { + capabilities = lsp_capabilities, + on_attach = onattach, + flags = {debounce_text_changes = 500} + } +end -lsp.setup_servers({ - 'clangd', - 'rust_analyzer', - 'lua_ls', -}) +vim.api.nvim_create_autocmd('LspAttach', { + desc = 'LSP actions', + callback = function() + local bufmap = function(mode, lhs, rhs) + local opts = {buffer = true} + vim.keymap.set(mode, lhs, rhs, opts) + end --- Fix Undefined global 'vim' -lsp.nvim_workspace() + bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>') + bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>') + bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>') + bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>') + bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>') + bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>') + bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>') + bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>') + bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>') + bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>') + bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>') + bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>') + end +}) +require('luasnip.loaders.from_vscode').lazy_load() local cmp = require('cmp') -local cmp_select = {behavior = cmp.SelectBehavior.Select} -local cmp_mappings = lsp.defaults.cmp_mappings({ - ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), - ['<C-n>'] = cmp.mapping.select_next_item(cmp_select), - ['<C-y>'] = cmp.mapping.confirm({ select = true }), - ["<C-Space>"] = cmp.mapping.complete(), -}) +local luasnip = require('luasnip') -cmp_mappings['<Tab>'] = nil -cmp_mappings['<S-Tab>'] = nil +local select_opts = {behavior = cmp.SelectBehavior.Select} +cmp.setup({ + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon = { + nvim_lsp = 'λ', + luasnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + item.menu = menu_icon[entry.source.name] + return item + end, + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + sources = { + {name = 'path'}, + {name = 'nvim_lsp', keyword_length = 1}, + {name = 'buffer', keyword_length = 3}, + {name = 'luasnip', keyword_length = 2}, + }, + mapping = { + ['<Up>'] = cmp.mapping.select_prev_item(select_opts), + ['<Down>'] = cmp.mapping.select_next_item(select_opts), -lsp.setup_nvim_cmp({ - mapping = cmp_mappings -}) + ['<C-p>'] = cmp.mapping.select_prev_item(select_opts), + ['<C-n>'] = cmp.mapping.select_next_item(select_opts), -lsp.set_preferences({ - suggest_lsp_servers = false, - sign_icons = { - error = 'E', - warn = 'W', - hint = 'H', - info = 'I' - } -}) + ['<C-u>'] = cmp.mapping.scroll_docs(-4), + ['<C-d>'] = cmp.mapping.scroll_docs(4), -lsp.on_attach(function(client, bufnr) - local opts = {buffer = bufnr, remap = false} - - vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) - vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) - vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts) - vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts) - vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) - vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) - vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts) - vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts) - vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts) - vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts) -end) - -lsp.setup() - -vim.diagnostic.config({ - virtual_text = true + ['<C-e>'] = cmp.mapping.abort(), + ['<C-y>'] = cmp.mapping.confirm({select = true}), + ['<CR>'] = cmp.mapping.confirm({select = false}), + }, }) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index 8dae86b..7eeb0a1 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -1,4 +1,4 @@ -local builtin = require('telescope.builtin') +local builtin = require "telescope.builtin" vim.keymap.set('n', '<leader>pf', builtin.find_files, {}) -vim.keymap.set('n', '<C-p>', builtin.git_files, {}) -vim.keymap.set('n', '<C-g>', builtin.live_grep, {}) +vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) +vim.keymap.set('n', '<leader>ff', builtin.buffers, {}) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua deleted file mode 100644 index 86826a0..0000000 --- a/after/plugin/treesitter.lua +++ /dev/null @@ -1,21 +0,0 @@ -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" (the five listed parsers should always be installed) - ensure_installed = { "zig", "rust", "c", "lua", "vim", "vimdoc", "query" }, - - -- 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, - - highlight = { - 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, - }, -} |