From 9de13c05de8e549d2d4e28f5de129fd29693f095 Mon Sep 17 00:00:00 2001 From: Vlad Date: Tue, 21 Nov 2023 17:00:33 +0300 Subject: [PATCH] init --- .gitignore | 1 + after/plugin/colors.lua | 8 ++++++ after/plugin/dap.lua | 7 ++++++ after/plugin/fugitive.lua | 1 + after/plugin/harpoon.lua | 5 ++++ after/plugin/lsp.lua | 49 +++++++++++++++++++++++++++++++++++++ after/plugin/telescope.lua | 8 ++++++ after/plugin/treesitter.lua | 30 +++++++++++++++++++++++ after/plugin/undotree.lua | 1 + init.lua | 2 ++ lua/nefrace/init.lua | 2 ++ lua/nefrace/packer.lua | 45 ++++++++++++++++++++++++++++++++++ lua/nefrace/remap.lua | 2 ++ lua/nefrace/set.lua | 34 +++++++++++++++++++++++++ 14 files changed, 195 insertions(+) create mode 100644 .gitignore create mode 100644 after/plugin/colors.lua create mode 100644 after/plugin/dap.lua create mode 100644 after/plugin/fugitive.lua create mode 100644 after/plugin/harpoon.lua create mode 100644 after/plugin/lsp.lua create mode 100644 after/plugin/telescope.lua create mode 100644 after/plugin/treesitter.lua create mode 100644 after/plugin/undotree.lua create mode 100644 init.lua create mode 100644 lua/nefrace/init.lua create mode 100644 lua/nefrace/packer.lua create mode 100644 lua/nefrace/remap.lua create mode 100644 lua/nefrace/set.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c84aa4a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +plugin/packer_compiled.lua diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua new file mode 100644 index 0000000..cdcfef4 --- /dev/null +++ b/after/plugin/colors.lua @@ -0,0 +1,8 @@ +function Color(color) + color = color or "rose-pine" + vim.cmd.colorscheme(color) +-- vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) +-- vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) +end + +Color() diff --git a/after/plugin/dap.lua b/after/plugin/dap.lua new file mode 100644 index 0000000..f61c602 --- /dev/null +++ b/after/plugin/dap.lua @@ -0,0 +1,7 @@ +local dap = require('dap') + +dap.adapters.godot = { + type = "server", + host = "127.0.0.1", + port = 6006, +} diff --git a/after/plugin/fugitive.lua b/after/plugin/fugitive.lua new file mode 100644 index 0000000..80c9070 --- /dev/null +++ b/after/plugin/fugitive.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "gs", vim.cmd.Git) diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua new file mode 100644 index 0000000..2308cf4 --- /dev/null +++ b/after/plugin/harpoon.lua @@ -0,0 +1,5 @@ +local mark = require("harpoon.mark") +local ui = require("harpoon.ui") + +vim.keymap.set("n", "a", mark.add_file) +vim.keymap.set("n", "", ui.toggle_quick_menu) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..34524d1 --- /dev/null +++ b/after/plugin/lsp.lua @@ -0,0 +1,49 @@ +local lsp = require("lsp-zero") + + +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(), +}) + +cmp.setup({ + sources = { + {name = 'path'}, + {name = 'nvim_lsp'}, + {name = 'nvim_lua'}, + }, + formatting = lsp.cmp_format(), + mapping = cmp.mapping.preset.insert(cmp_mappings) +}) + +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", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "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", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("n", "", function() vim.lsp.buf.signature_help() end, opts) + +end) + +require('mason').setup({}) +require('mason-lspconfig').setup({ + ensure_installed = {'tsserver', 'eslint', 'rust_analyzer', 'gopls'}, + handlers = { + lsp.default_setup, + lua_ls = function() + local lua_opts = lsp.nvim_lua_ls() + require('lspconfig').lua_ls.setup(lua_opts) + end, + } +}) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua new file mode 100644 index 0000000..e4702e0 --- /dev/null +++ b/after/plugin/telescope.lua @@ -0,0 +1,8 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'pf', builtin.find_files, {}) +vim.keymap.set('n', '', builtin.git_files, {}) +vim.keymap.set('n', 'pb', builtin.buffers, {}) +vim.keymap.set('n', 'ph', builtin.help_tags, {}) +vim.keymap.set('n', 'ps', function() + builtin.grep_string({search = vim.fn.input("Grep > ") }) +end) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..ae0f1cd --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,30 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "javascript", "typescript", "c", "lua", "vim", "vimdoc", "query", "rust", "go" }, + + -- 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, + + + ---- 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 = { + enable = true, + + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + + -- 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..b6b9276 --- /dev/null +++ b/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..909d1cb --- /dev/null +++ b/init.lua @@ -0,0 +1,2 @@ +require("nefrace") + diff --git a/lua/nefrace/init.lua b/lua/nefrace/init.lua new file mode 100644 index 0000000..727c90d --- /dev/null +++ b/lua/nefrace/init.lua @@ -0,0 +1,2 @@ +require("nefrace.remap") +require("nefrace.set") diff --git a/lua/nefrace/packer.lua b/lua/nefrace/packer.lua new file mode 100644 index 0000000..ba4850e --- /dev/null +++ b/lua/nefrace/packer.lua @@ -0,0 +1,45 @@ +-- This file can be loaded by calling `lua require('plugins')` from your init.vim + +-- Only required if you have packer configured as `opt` +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.4', + requires = { {'nvim-lua/plenary.nvim' } } + } + + use({ + 'rose-pine/neovim', + as = 'rose-pine', + config = function() + vim.cmd('colorscheme rose-pine') + end + }) + + use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) + use('theprimeagen/harpoon') + use('mbbill/undotree') + use('tpope/vim-fugitive') + use('mfussenegger/nvim-dap') + + + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + requires = { + --- Uncomment these if you want to manage LSP servers from neovim + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + + -- LSP Support + {'neovim/nvim-lspconfig'}, + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'L3MON4D3/LuaSnip'}, + } +} +end) diff --git a/lua/nefrace/remap.lua b/lua/nefrace/remap.lua new file mode 100644 index 0000000..b760350 --- /dev/null +++ b/lua/nefrace/remap.lua @@ -0,0 +1,2 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "pv", vim.cmd.Ex) diff --git a/lua/nefrace/set.lua b/lua/nefrace/set.lua new file mode 100644 index 0000000..183a560 --- /dev/null +++ b/lua/nefrace/set.lua @@ -0,0 +1,34 @@ +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.backup = false +vim.opt.swapfile = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +vim.opt.colorcolumn = "80" + +vim.g.mapleader = " " +