diff options
Diffstat (limited to 'nvim')
-rw-r--r-- | nvim/.config/nvim/after/ftplugin/lua.lua | 3 | ||||
-rw-r--r-- | nvim/.config/nvim/init.lua | 42 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins.lua | 65 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/ccls.lua | 24 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/completion.lua | 65 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/git.lua | 6 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua | 65 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/telescope.lua | 137 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/lazy-plugins/treesitter.lua | 47 | ||||
-rw-r--r-- | nvim/.config/nvim/lua/options.lua | 59 |
10 files changed, 513 insertions, 0 deletions
diff --git a/nvim/.config/nvim/after/ftplugin/lua.lua b/nvim/.config/nvim/after/ftplugin/lua.lua new file mode 100644 index 0000000..cbbe688 --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/lua.lua @@ -0,0 +1,3 @@ +vim.opt_local.expandtab = true +vim.opt_local.softtabstop = 2 +vim.opt_local.shiftwidth = 2 diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..da14476 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,42 @@ +vim.g.loaded_ruby_provider = 0 +vim.g.loaded_node_provider = 0 +vim.g.loaded_perl_provider = 0 + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + -- bootstrap lazy.nvim + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", + lazypath }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +require("lazy").setup({ + spec = { + { import = "lazy-plugins" }, + }, + defaults = { + -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. + -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + lazy = false, + version = "*", -- try installing the latest stable version for plugins that support semver + }, + install = { colorscheme = { "tokyonight", "habamax" } }, + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) + +require('options') diff --git a/nvim/.config/nvim/lua/lazy-plugins.lua b/nvim/.config/nvim/lua/lazy-plugins.lua new file mode 100644 index 0000000..602146f --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins.lua @@ -0,0 +1,65 @@ +vim.g.table_mode_corner = "|" + +-- Put simply configured plugins here. +return { + { "lukas-reineke/indent-blankline.nvim", version = "v3.5.4", main = "ibl", opts = {} }, + { + "Mofiqul/adwaita.nvim", + lazy = false, + priority = 1000, + config = function() + vim.g.adwaita_darker = true + vim.cmd("colorscheme adwaita") + end + }, + { "norcalli/nvim-terminal.lua", opts = {} }, + "dhruvasagar/vim-table-mode", + { + "ibhagwan/fzf-lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, + { + "kylechui/nvim-surround", + event = "VeryLazy", + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end + }, + "tpope/vim-eunuch", + "vim-scripts/git_patch_tags.vim", + { + "nvim-lualine/lualine.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons" + }, + }, + { + 'numToStr/Comment.nvim', + opts = { + -- add any options here + }, + lazy = false, + }, + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = true + }, + { + "rktjmp/paperplanes.nvim", + opts = { + register = "+", + provider = "sprunge.us", + provider_options = { insecure = true, }, + notifier = vim.notify or print, + }, + }, + { + "j-hui/fidget.nvim", + tag = "legacy", + event = "LspAttach", + opts = {}, + }, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/ccls.lua b/nvim/.config/nvim/lua/lazy-plugins/ccls.lua new file mode 100644 index 0000000..1ae961c --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/ccls.lua @@ -0,0 +1,24 @@ +local M = { + "ranjithshegde/ccls.nvim", + dependencies = { "neovim/nvim-lspconfig" }, +} + +M.config = function() + local ccls = require("ccls") + ccls.setup({ + lsp = { + -- check :help vim.lsp.start for config options + server = { + name = "ccls", --String name + cmd = {"/usr/bin/ccls"}, -- point to your binary, has to be a table + args = {--[[Any args table]] }, + offset_encoding = "utf-32", -- default value set by plugin + root_dir = vim.fs.dirname(vim.fs.find({ "compile_commands.json", ".git" }, { upward = true })[1]), -- or some other function that returns a string + --on_attach = your_func, + --capabilites = your_table/func + }, + }, + }) +end + +return M diff --git a/nvim/.config/nvim/lua/lazy-plugins/completion.lua b/nvim/.config/nvim/lua/lazy-plugins/completion.lua new file mode 100644 index 0000000..01fc0d8 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/completion.lua @@ -0,0 +1,65 @@ +local M = { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", + { + "L3MON4D3/LuaSnip", + tag = "v2.1.1", + }, + }, +} + +M.config = function() + local cmp = require("cmp") + vim.opt.completeopt = { "menu", "menuone", "noselect" } + + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + ["<Tab>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + ["<S-Tab>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + ["<C-d>"] = 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({}), + ["<S-CR>"] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "luasnip" }, -- For luasnip users. + -- { name = "orgmode" }, + }, { + { name = "buffer" }, + { name = "path" }, + }), + }) + + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) +end + +return M diff --git a/nvim/.config/nvim/lua/lazy-plugins/git.lua b/nvim/.config/nvim/lua/lazy-plugins/git.lua new file mode 100644 index 0000000..dfd6e63 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/git.lua @@ -0,0 +1,6 @@ +return { + { + "tpope/vim-fugitive", + cmd = "Git", + } +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua b/nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua new file mode 100644 index 0000000..75537c0 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/mason-lsp.lua @@ -0,0 +1,65 @@ +return { + { + "neovim/nvim-lspconfig", + name = "lspconfig", + lazy = false, + dependencies = { + { "williamboman/mason-lspconfig.nvim", name = "mason-lspconfig" }, + { "williamboman/mason.nvim", name = "mason" }, + }, + config = function() + local lspconfig = require("lspconfig") + local mason = require("mason") + local mason_lspconfig = require("mason-lspconfig") + local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) + local servers = { "lua_ls", "marksman", "pylsp" } +-- local options = { noremap = true, silent = true } + + mason.setup({}) + + mason_lspconfig.setup({ ensure_installed = servers }) + + mason_lspconfig.setup_handlers({ + function(server_name) + lspconfig[server_name].setup({ + capabilities = capabilities, + }) + end, + ["lua_ls"] = function() + lspconfig.lua_ls.setup { + settings = { + Lua = { + runtime = { version = 'LuaJIT', }, + diagnostics = { + globals = { + 'vim', + 'require', + }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + telemetry = { enable = false }, + }, + }, + } + end, + ["pylsp"] = function() + lspconfig.pylsp.setup { + settings = { + pylsp = { + plugins = { + pycodestyle = { + ignore = {'W391'}, + maxLineLength = 100, + } + }, + }, + }, + } + end + }) + end + }, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/telescope.lua b/nvim/.config/nvim/lua/lazy-plugins/telescope.lua new file mode 100644 index 0000000..cf3f151 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/telescope.lua @@ -0,0 +1,137 @@ +return { + { + "nvim-telescope/telescope.nvim", + lazy = true, + dependencies = { + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }, + "nvim-tree/nvim-web-devicons", + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-symbols.nvim", + }, + cmd = "Telescope", + keys = { + { "gr", function() require('telescope.builtin').lsp_references() end }, + { "<leader>fr", function() require('telescope.builtin').lsp_references() end }, + { "<leader>ff", "<cmd>Telescope find_files<cr>" }, + { "<leader>fo", "<cmd>Telescope oldfiles<cr>" }, + { "<leader>fg", "<cmd>Telescope live_grep<cr>" }, + { "<leader>fb", "<cmd>Telescope buffers<cr>" }, + { "<leader>fh", "<cmd>Telescope help_tags<cr>" }, + { "<leader>fs", "<cmd>Telescope grep_string<cr>" }, + }, + config = function() + local always_ignore_these = { + "yarn.lock", -- nodejs + "package%-lock.json", -- nodejs + "node_modules/.*", -- nodejs + "vendor/*", -- golang + "%.git/.*", + "%.png", + "%.jpeg", + "%.jpg", + "%.ico", + "%.webp", + "%.avif", + "%.heic", + "%.mp3", + "%.mp4", + "%.mkv", + "%.mov", + "%.wav", + "%.flv", + "%.avi", + "%.webm", + "%.db", + } + + require("telescope").setup({ + defaults = { + mappings = { + i = { + -- don't go into normal mode, just close + ["<Esc>"] = require("telescope.actions").close, + -- scroll the list with <c-j> and <c-k> + ["<C-j>"] = require("telescope.actions").move_selection_next, + ["<C-k>"] = require("telescope.actions").move_selection_previous, + -- move the preview window up and down + ["<C-u>"] = require("telescope.actions").preview_scrolling_up, + ["<C-d>"] = require("telescope.actions").preview_scrolling_down, + }, + }, + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + "--trim", + }, + layout_strategy = "flex", + layout_config = { + prompt_position = "top", + horizontal = { + mirror = true, + preview_cutoff = 100, + preview_width = 0.5, + }, + vertical = { + mirror = true, + preview_cutoff = 0.4, + }, + flex = { + flip_columns = 110, + }, + height = 0.94, + width = 0.86, + }, + prompt_prefix = " ", + selection_caret = " ", + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "ascending", + file_sorter = require("telescope.sorters").get_fuzzy_file, + file_ignore_patterns = always_ignore_these, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + path_display = { "truncate" }, + winblend = 0, + border = {}, + borderchars = { + "─", + "│", + "─", + "│", + "╭", + "╮", + "╯", + "╰", + }, + color_devicons = true, + use_less = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + -- Developer configurations: Not meant for general override + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + }, + pickers = { + find_files = { + find_command = { "fd", "--type", "f", "--strip-cwd-prefix" }, + hidden = true, + }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + }, + }) + end + }, +} diff --git a/nvim/.config/nvim/lua/lazy-plugins/treesitter.lua b/nvim/.config/nvim/lua/lazy-plugins/treesitter.lua new file mode 100644 index 0000000..c1b9cf2 --- /dev/null +++ b/nvim/.config/nvim/lua/lazy-plugins/treesitter.lua @@ -0,0 +1,47 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = function() + pcall(require("nvim-treesitter.install").update({ with_sync = true })) + end, + event = "BufReadPost", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + opts = { + highlight = { enable = true }, + indent = { enable = true }, + context_commentstring = { enable = true, enable_autocmd = false }, + ensure_installed = { + "bash", + "c", + "cmake", + "cpp", + "dockerfile", + "git_config", + "gitattributes", + "gitcommit", + "gitignore", + "go", + "ini", + "javascript", + "jsdoc", + "json", + "json5", + "lua", + "make", + "markdown", + "meson", + "ninja", + "python", + "rust", + "toml", + "vim", + "yaml", + }, + }, + config = function(plugin, opts) + require("nvim-treesitter.configs").setup(opts) + end, + }, +} diff --git a/nvim/.config/nvim/lua/options.lua b/nvim/.config/nvim/lua/options.lua new file mode 100644 index 0000000..681fa71 --- /dev/null +++ b/nvim/.config/nvim/lua/options.lua @@ -0,0 +1,59 @@ +-- show line numbers +vim.opt.number = true +vim.opt.relativenumber = true + +-- Color the colum to the right of the limit +vim.opt.colorcolumn = "+1" + +-- Options for completions. Move this at some point. +-- have a fixed column for the diagnostics to appear in this removes the jitter when warnings/errors flow in +vim.wo.signcolumn = "yes" +vim.cmd([[autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })]]) + +--Set completeopt to have a better completion experience +-- :help completeopt +-- menuone: popup even when there's only one match +-- noinsert: Do not insert text until a selection is made +-- noselect: Do not select, force to select one from the menu +-- shortness: avoid showing extra messages when using completion +-- updatetime: set updatetime for CursorHold +vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} +vim.opt.shortmess = vim.opt.shortmess + { c = true} +vim.api.nvim_set_option('updatetime', 300) + +vim.keymap.set('n', '<Leader>gr', ':FzfLua grep_project<cr>', { noremap = true, silent = true }) +vim.keymap.set('n', '<Leader>gg', ':FzfLua git_files<cr>', { noremap = true, silent = true }) +vim.keymap.set('n', '<Leader>gf', ':FzfLua files<cr>', { noremap = true, silent = true }) + +vim.keymap.set('n', '<Leader>e', vim.diagnostic.open_float) +vim.keymap.set('n', '<Leader>E', vim.diagnostic.setloclist) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by <c-x><c-o> + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local options = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, options) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, options) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, options) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, options) + vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, options) + vim.keymap.set('n', '<c-\\>c', vim.lsp.buf.incoming_calls, options) + vim.keymap.set({'n', 'v'}, '<Leader>ca', vim.lsp.buf.code_action, options) + vim.keymap.set('n', '<Leader>rn', vim.lsp.buf.rename, options) + vim.keymap.set('n', '<c-\\>g', vim.lsp.buf.references, options) + vim.keymap.set('n', '<space>f', function () + vim.lsp.buf.format{ async = true } + end, options) + end, +}) + +vim.o.termguicolors = true |