From 2a3ee1c8f696e6f3a9972a05f8b5f8681c244a2e Mon Sep 17 00:00:00 2001 From: philw Date: Sat, 17 Feb 2024 12:42:20 +0100 Subject: Migrate to lazy and coq --- init.lua | 169 +++++++++++++++++++++++++++++++++++++++++++++++-- lua/config/editor.lua | 25 ++------ lua/config/lsp.lua | 114 ++++++++++++++++----------------- lua/config/packer.lua | 57 ----------------- lua/config/plugins.lua | 83 ++++++++++++++++++++++++ 5 files changed, 307 insertions(+), 141 deletions(-) delete mode 100644 lua/config/packer.lua create mode 100644 lua/config/plugins.lua diff --git a/init.lua b/init.lua index 45e6811..87a9b46 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,165 @@ ---Open this file if you want to add new plugins -require("config.packer") +-- require("config.lsp") +local option = vim.opt +local keymap = vim.keymap --- Here you can find stuff related to lsp -require("config.lsp") +--Basic Editor Setup +option.nu = true +option.tabstop = 2 +option.softtabstop = 2 +option.shiftwidth = 2 +option.expandtab = true +option.smartindent = true +option.wrap = false +option.swapfile = false +option.hlsearch = false +option.incsearch = true +option.updatetime = 50 +option.laststatus = 0 +option.signcolumn = "number" +option.autoindent = true +option.clipboard = "unnamedplus" +option.termguicolors = true +option.fillchars = 'eob: ' +option.autoindent = true --- And there goes editor customization -require("config.editor") +-- Setup Editor Theme +vim.cmd([[ +highlight GitGutterAdd ctermbg=none +highlight GitGutterAdd guibg=none +highlight NonText guifg=none +highlight EndOfBuffer ctermfg=none ctermbg=none +highlight Normal ctermbg=none +highlight Normal guibg=none +highlight signcolumn ctermbg=none +highlight signcolumn guibg=none +highlight StatusLine ctermbg=none +highlight StatusLine guibg=none +highlight DiagnosticError ctermbg=none +highlight DiagnosticError guibg=none +highlight DiagnosticWarn ctermbg=none +highlight DiagnosticWarn guibg=none +highlight DiagnosticInfo ctermbg=none +highlight DiagnosticInfo guibg=none +highlight DiagnosticHint ctermbg=none +highlight DiagnosticHint guibg=none +highlight Pmenu ctermbg=none guibg=none + +highlight DiagnosticVirtualError ctermbg=none +highlight DiagnosticVirtualError guibg=none +highlight DiagnosticVirtualWarn ctermbg=none +highlight DiagnosticVirtualWarn guibg=none +highlight DiagnosticVirtualInfo ctermbg=none +highlight DiagnosticVirtualInfo guibg=none +highlight DiagnosticVirtualHint ctermbg=none +highlight DiagnosticVirtualHint guibg=none + +highlight DiagnosticVirtualTextError ctermbg=none +highlight DiagnosticVirtualTextError guibg=none +highlight DiagnosticVirtualTextWarn ctermbg=none +highlight DiagnosticVirtualTextWarn guibg=none +highlight DiagnosticVirtualTextInfo ctermbg=none +highlight DiagnosticVirtualTextInfo guibg=none +highlight DiagnosticVirtualTextHint ctermbg=none +highlight DiagnosticVirtualTextHint guibg=none +]]) + +-- run specific commands after different file extensions +vim.cmd([[ +augroup RunPfOnSave +autocmd! +autocmd BufWritePost *.js,*.ts,*.jsx,*json,*.tsx,*.css,*.html,*.yaml,*.md silent! !prettier --write % +autocmd BufWritePost *.tex silent! :VimtexCompile +autocmd BufWritePost *.md silent! :MarkdownPreview +autocmd BufWritePost *.php silent! !php-cs-fixer fix % +augroup END +]]) + +-- Gui options +vim.o.guifont = "Fira Code:h7" +vim.g.vimtex_view_method = "zathura" +vim.g.vimtex_compiler_method = "latexrun" +vim.g.gitgutter_set_sign_backgrounds = 1 + +--Keybinds +vim.g.mapleader = " " +keymap.set("n", "e", vim.cmd.Ex) +keymap.set("n", "s", [[:%s/\<\>//gI]]) +keymap.set("n", "a", "ggVG") +keymap.set("v", "J", ":m '>+1gv=gv") +keymap.set("v", "K", ":m '<-2gv=gv") +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end + +vim.opt.rtp:prepend(lazypath) +require("lazy").setup({ + "nvim-lua/plenary.nvim", + "airblade/vim-gitgutter", + "nvim-treesitter/nvim-treesitter", + "neovim/nvim-lspconfig", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + 'nvim-telescope/telescope.nvim', + tag = '0.1.5', + dependencies = { 'nvim-lua/plenary.nvim' }, + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup({}) + end, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = + 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', + keys = { + { "/", false }, + { "f", "Telescope find_files", desc = "Find Files" }, + { "g", "Telescope live_grep", desc = "Grep" }, + { "b", "Telescope buffers", desc = "Grep" }, + } + }, + { + 'numToStr/Comment.nvim', + }, + + 'ms-jpq/coq_nvim', + { 'ms-jpq/coq.artifacts', branch = "artifacts" }, +}) + + +vim.api.nvim_create_autocmd('InsertEnter', { + command = 'COQnow --shut-up' +}) +local lsp_servers = { + clangd = {}, + lua_ls = {}, +} +require("mason").setup() +require("mason-lspconfig").setup { + ensure_installed = lsp_servers, + automatic_installation = true, +} + +local server_maps = function(opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- goto def + vim.keymap.set("n", "k", vim.lsp.buf.hover, opts) -- see docs + vim.keymap.set("n", "fo", function() -- format + vim.lsp.buf.format({ async = true }) + end, opts) +end + +for lsp, settings in pairs(lsp_servers) do + require("lspconfig")[lsp].setup(coq.lsp_ensure_capabilities({ + on_attach = function(_, buffer) + server_maps({ buffer = buffer }) + end, + settings = settings, + })) +end diff --git a/lua/config/editor.lua b/lua/config/editor.lua index eec0e08..a4ce545 100644 --- a/lua/config/editor.lua +++ b/lua/config/editor.lua @@ -1,10 +1,6 @@ -local js_based_languages = { "typescript", "javascript", "typescriptreact", "javascriptreact" } local option = vim.opt local keymap = vim.keymap -local telescope = require("telescope.builtin") -local autotag = require("nvim-ts-autotag").setup() - --Basic Editor Setup option.nu = true option.tabstop = 2 @@ -21,13 +17,15 @@ option.laststatus = 0 option.signcolumn = "number" option.autoindent = true option.clipboard = "unnamedplus" -option.termguicolors = true +option.termguicolors = false +option.fillchars='eob: ' -- Setup Editor Theme -vim.cmd.colorscheme("tokyonight") vim.cmd([[ highlight GitGutterAdd ctermbg=none highlight GitGutterAdd guibg=none +highlight NonText guifg=none +highlight EndOfBuffer ctermfg=none ctermbg=none highlight Normal ctermbg=none highlight Normal guibg=none highlight signcolumn ctermbg=none @@ -62,7 +60,6 @@ highlight DiagnosticVirtualTextHint ctermbg=none highlight DiagnosticVirtualTextHint guibg=none ]]) - -- run specific commands after different file extensions vim.cmd([[ augroup RunPfOnSave @@ -83,21 +80,7 @@ vim.g.gitgutter_set_sign_backgrounds = 1 --Keybinds vim.g.mapleader = " " keymap.set("n", "e", vim.cmd.Ex) -keymap.set("n", "f", telescope.find_files, {}) -keymap.set("n", "fg", telescope.live_grep, {}) -keymap.set("n", "fb", telescope.buffers, {}) -keymap.set("n", "fh", telescope.help_tags, {}) keymap.set("n", "s", [[:%s/\<\>//gI]]) keymap.set("n", "a", "ggVG") keymap.set("v", "J", ":m '>+1gv=gv") keymap.set("v", "K", ":m '<-2gv=gv") - ---Treesitter -require("nvim-treesitter.configs").setup({ - ensure_installed = { "javascript", "typescript", "rust", "c", "lua", "vim" }, - sync_install = false, - auto_install = true, - highlight = { - enable = true, - }, -}) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index ca341d5..7fd0ddb 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -1,64 +1,64 @@ -- local lsp = require('lsp-zero') -local lsp_zero = require("lsp-zero") -local cmp = require("cmp") -require("luasnip.loaders.from_vscode").lazy_load() +--local lsp_zero = require("lsp-zero") +--local cmp = require("cmp") +--require("luasnip.loaders.from_vscode").lazy_load() -lsp_zero.preset("recommended") -lsp_zero.setup() -lsp_zero.on_attach(function(client_id, bufnr) - lsp_zero.default_keymaps({ buffer = bufnr }) -end) +--lsp_zero.preset("recommended") +--lsp_zero.setup() +--lsp_zero.on_attach(function(client_id, bufnr) +-- lsp_zero.default_keymaps({ buffer = bufnr }) +--end) -require("mason").setup({}) -require("mason-lspconfig").setup({ - ensure_installed = { "clangd", "rust_analyzer" }, - handlers = { - lsp_zero.default_setup, - }, -}) +--require("mason").setup({}) +--require("mason-lspconfig").setup({ +-- ensure_installed = { "clangd", "rust_analyzer" }, +-- handlers = { +-- lsp_zero.default_setup, +-- }, +--}) -cmp.setup({ - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - window = {}, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - }, { - { name = "buffer" }, - }), -}) +--cmp.setup({ +-- snippet = { +-- expand = function(args) +-- require("luasnip").lsp_expand(args.body) +-- end, +-- }, +-- window = {}, +-- mapping = cmp.mapping.preset.insert({ +-- [""] = cmp.mapping.scroll_docs(-4), +-- [""] = cmp.mapping.scroll_docs(4), +-- [""] = cmp.mapping.complete(), +-- [""] = cmp.mapping.abort(), +-- [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. +-- }), +-- sources = cmp.config.sources({ +-- { name = "nvim_lsp" }, +-- { name = "luasnip" }, +-- }, { +-- { name = "buffer" }, +-- }), +--}) -function PrintDiagnostics(opts, bufnr, line_nr, client_id) - bufnr = bufnr or 0 - line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) - opts = opts or { ["lnum"] = line_nr } +--function PrintDiagnostics(opts, bufnr, line_nr, client_id) +-- bufnr = bufnr or 0 +-- line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) +-- opts = opts or { ["lnum"] = line_nr } +-- +-- local line_diagnostics = vim.diagnostic.get(bufnr, opts) +-- if vim.tbl_isempty(line_diagnostics) then +-- return +-- end +-- +-- local diagnostic_message = "" +-- for i, diagnostic in ipairs(line_diagnostics) do +-- diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") +-- print(diagnostic_message) +-- if i ~= #line_diagnostics then +-- diagnostic_message = diagnostic_message .. "\n" +-- end +-- end +-- vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) +--end - local line_diagnostics = vim.diagnostic.get(bufnr, opts) - if vim.tbl_isempty(line_diagnostics) then - return - end - - local diagnostic_message = "" - for i, diagnostic in ipairs(line_diagnostics) do - diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") - print(diagnostic_message) - if i ~= #line_diagnostics then - diagnostic_message = diagnostic_message .. "\n" - end - end - vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {}) -end - -vim.cmd([[ autocmd! CursorHold * lua PrintDiagnostics() ]]) +--vim.cmd([[ autocmd! CursorHold * lua PrintDiagnostics() ]]) diff --git a/lua/config/packer.lua b/lua/config/packer.lua deleted file mode 100644 index 07a600a..0000000 --- a/lua/config/packer.lua +++ /dev/null @@ -1,57 +0,0 @@ -vim.cmd([[packadd packer.nvim]]) -return require("packer").startup(function(use) - use("wbthomason/packer.nvim") - use("nvim-treesitter/nvim-treesitter") - use("neovim/nvim-lspconfig") - use("lukas-reineke/indent-blankline.nvim") - use("lervag/vimtex") - use("folke/tokyonight.nvim") - use("airblade/vim-gitgutter") - use("jose-elias-alvarez/null-ls.nvim") - use("windwp/nvim-ts-autotag") - use({ - "nvim-telescope/telescope.nvim", - tag = "0.1.4", - requires = { { "nvim-lua/plenary.nvim" } }, - }) - use({ - "VonHeikemen/lsp-zero.nvim", - requires = { - { "neovim/nvim-lspconfig" }, - { "williamboman/mason.nvim" }, - { "williamboman/mason-lspconfig.nvim" }, - { "hrsh7th/nvim-cmp" }, - { "hrsh7th/cmp-buffer" }, - { "hrsh7th/cmp-path" }, - { "saadparwaiz1/cmp_luasnip" }, - { "hrsh7th/cmp-nvim-lsp" }, - { "hrsh7th/cmp-nvim-lua" }, - { "rafamadriz/friendly-snippets" }, - }, - }) - use({ - "L3MON4D3/LuaSnip", - tag = "v2.*", - run = "make install_jsregexp", - }) - use({ - "numToStr/Comment.nvim", - config = function() - require("Comment").setup() - end, - }) - use({ - "iamcco/markdown-preview.nvim", - run = "cd app && npm install", - setup = function() - vim.g.mkdp_filetypes = { "markdown" } - end, - ft = { "markdown" }, - }) - use({ - "windwp/nvim-autopairs", - config = function() - require("nvim-autopairs").setup({}) - end, - }) -end) diff --git a/lua/config/plugins.lua b/lua/config/plugins.lua new file mode 100644 index 0000000..dd09a4d --- /dev/null +++ b/lua/config/plugins.lua @@ -0,0 +1,83 @@ +-- vim.cmd([[packadd packer.nvim]]) +-- return require("packer").startup(function(use) +-- use("neovim/nvim-lspconfig") +-- use("lervag/vimtex") +-- use({ +-- "VonHeikemen/lsp-zero.nvim", +-- requires = { +-- { "neovim/nvim-lspconfig" }, +-- { "williamboman/mason.nvim" }, +-- { "williamboman/mason-lspconfig.nvim" }, +-- { "hrsh7th/nvim-cmp" }, +-- { "hrsh7th/cmp-buffer" }, +-- { "hrsh7th/cmp-path" }, +-- { "saadparwaiz1/cmp_luasnip" }, +-- { "hrsh7th/cmp-nvim-lsp" }, +-- { "hrsh7th/cmp-nvim-lua" }, +-- { "rafamadriz/friendly-snippets" }, +-- }, +-- }) +-- use({ +-- "L3MON4D3/LuaSnip", +-- tag = "v2.*", +-- run = "make install_jsregexp", +-- }) +-- use({ +-- "iamcco/markdown-preview.nvim", +-- run = "cd app && npm install", +-- setup = function() +-- vim.g.mkdp_filetypes = { "markdown" } +-- end, +-- ft = { "markdown" }, +-- }) +-- use({ +-- "windwp/nvim-autopairs", +-- config = function() +-- require("nvim-autopairs").setup({}) +-- end, +-- }) +-- end) + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end + +vim.opt.rtp:prepend(lazypath) +require("lazy").setup({ + "nvim-lua/plenary.nvim", + "airblade/vim-gitgutter", + "nvim-treesitter/nvim-treesitter", + "neovim/nvim-lspconfig", + 'nvim-telescope/telescope.nvim', tag = '0.1.5', + dependencies = { 'nvim-lua/plenary.nvim' }, + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup({}) + end, + { 'nvim-telescope/telescope-fzf-native.nvim', + build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', + keys= { + {"/", false}, + { "f", "Telescope find_files", desc = "Find Files" }, + { "g", "Telescope live_grep", desc = "Grep" }, + { "b", "Telescope buffers", desc = "Grep" }, + } +}, +{ + 'numToStr/Comment.nvim', + lazy = false, +}, + +{ + "ms-jpq/coq_nvim", +}, +}) + -- cgit v1.2.3 From 8fbc8e095bcc907463bf93a62d3fc765bf6a3ceb Mon Sep 17 00:00:00 2001 From: philw Date: Sat, 17 Feb 2024 13:24:54 +0100 Subject: Enable autoparis --- init.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 87a9b46..f2c4641 100644 --- a/init.lua +++ b/init.lua @@ -110,10 +110,6 @@ require("lazy").setup({ 'nvim-telescope/telescope.nvim', tag = '0.1.5', dependencies = { 'nvim-lua/plenary.nvim' }, - "windwp/nvim-autopairs", - config = function() - require("nvim-autopairs").setup({}) - end, { 'nvim-telescope/telescope-fzf-native.nvim', build = @@ -125,6 +121,11 @@ require("lazy").setup({ { "b", "Telescope buffers", desc = "Grep" }, } }, + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + opts = {} -- this is equalent to setup({}) function + }, { 'numToStr/Comment.nvim', }, @@ -137,6 +138,7 @@ require("lazy").setup({ vim.api.nvim_create_autocmd('InsertEnter', { command = 'COQnow --shut-up' }) + local lsp_servers = { clangd = {}, lua_ls = {}, @@ -148,9 +150,9 @@ require("mason-lspconfig").setup { } local server_maps = function(opts) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- goto def - vim.keymap.set("n", "k", vim.lsp.buf.hover, opts) -- see docs - vim.keymap.set("n", "fo", function() -- format + vim.keymap.set("n", "d", vim.lsp.buf.definition, opts) -- goto def + vim.keymap.set("n", "k", vim.lsp.buf.hover, opts) -- see docs + vim.keymap.set("n", "fo", function() -- format vim.lsp.buf.format({ async = true }) end, opts) end -- cgit v1.2.3 From df216a4830635ffb117b441a60d890ad251f0a80 Mon Sep 17 00:00:00 2001 From: philw Date: Tue, 19 Mar 2024 21:10:16 +0100 Subject: Add colorizer support, enable vimtex --- init.lua | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index f2c4641..392b6d7 100644 --- a/init.lua +++ b/init.lua @@ -83,8 +83,12 @@ vim.g.gitgutter_set_sign_backgrounds = 1 --Keybinds vim.g.mapleader = " " keymap.set("n", "e", vim.cmd.Ex) -keymap.set("n", "s", [[:%s/\<\>//gI]]) +keymap.set("n", "z", [[:%s/\<\>//gI]]) keymap.set("n", "a", "ggVG") +keymap.set("n", "y", "cc") +keymap.set("n", "", "yy") +keymap.set("n", "", "p") +keymap.set("n", "", "u") keymap.set("v", "J", ":m '>+1gv=gv") keymap.set("v", "K", ":m '<-2gv=gv") local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" @@ -103,6 +107,8 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup({ "nvim-lua/plenary.nvim", "airblade/vim-gitgutter", + "lervag/vimtex", + "norcalli/nvim-colorizer.lua", "nvim-treesitter/nvim-treesitter", "neovim/nvim-lspconfig", "williamboman/mason.nvim", @@ -119,30 +125,40 @@ require("lazy").setup({ { "f", "Telescope find_files", desc = "Find Files" }, { "g", "Telescope live_grep", desc = "Grep" }, { "b", "Telescope buffers", desc = "Grep" }, + { "s", "Telescope buffers", desc = "Grep" }, } }, { 'windwp/nvim-autopairs', event = "InsertEnter", - opts = {} -- this is equalent to setup({}) function + opts = {} }, { 'numToStr/Comment.nvim', + opts = {}, + lazy = false, }, 'ms-jpq/coq_nvim', { 'ms-jpq/coq.artifacts', branch = "artifacts" }, }) - +require("colorizer").setup() vim.api.nvim_create_autocmd('InsertEnter', { command = 'COQnow --shut-up' }) +vim.api.nvim_create_autocmd("BufWritePre", { + callback = function() + vim.lsp.buf.format() + end, +}) + local lsp_servers = { clangd = {}, lua_ls = {}, } + require("mason").setup() require("mason-lspconfig").setup { ensure_installed = lsp_servers, @@ -152,9 +168,6 @@ require("mason-lspconfig").setup { local server_maps = function(opts) vim.keymap.set("n", "d", vim.lsp.buf.definition, opts) -- goto def vim.keymap.set("n", "k", vim.lsp.buf.hover, opts) -- see docs - vim.keymap.set("n", "fo", function() -- format - vim.lsp.buf.format({ async = true }) - end, opts) end for lsp, settings in pairs(lsp_servers) do -- cgit v1.2.3 From 9a0878a9157effaf5180a140f3413df406e42097 Mon Sep 17 00:00:00 2001 From: philw Date: Tue, 23 Apr 2024 21:26:13 +0200 Subject: Update nvim --- init.lua | 106 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 43 deletions(-) diff --git a/init.lua b/init.lua index 392b6d7..5417043 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,8 @@ -- require("config.lsp") local option = vim.opt local keymap = vim.keymap +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 --Basic Editor Setup option.nu = true @@ -22,48 +24,6 @@ option.termguicolors = true option.fillchars = 'eob: ' option.autoindent = true --- Setup Editor Theme -vim.cmd([[ -highlight GitGutterAdd ctermbg=none -highlight GitGutterAdd guibg=none -highlight NonText guifg=none -highlight EndOfBuffer ctermfg=none ctermbg=none -highlight Normal ctermbg=none -highlight Normal guibg=none -highlight signcolumn ctermbg=none -highlight signcolumn guibg=none -highlight StatusLine ctermbg=none -highlight StatusLine guibg=none -highlight DiagnosticError ctermbg=none -highlight DiagnosticError guibg=none -highlight DiagnosticWarn ctermbg=none -highlight DiagnosticWarn guibg=none -highlight DiagnosticInfo ctermbg=none -highlight DiagnosticInfo guibg=none -highlight DiagnosticHint ctermbg=none -highlight DiagnosticHint guibg=none -highlight Pmenu ctermbg=none guibg=none - -highlight DiagnosticVirtualError ctermbg=none -highlight DiagnosticVirtualError guibg=none -highlight DiagnosticVirtualWarn ctermbg=none -highlight DiagnosticVirtualWarn guibg=none -highlight DiagnosticVirtualInfo ctermbg=none -highlight DiagnosticVirtualInfo guibg=none -highlight DiagnosticVirtualHint ctermbg=none -highlight DiagnosticVirtualHint guibg=none - -highlight DiagnosticVirtualTextError ctermbg=none -highlight DiagnosticVirtualTextError guibg=none -highlight DiagnosticVirtualTextWarn ctermbg=none -highlight DiagnosticVirtualTextWarn guibg=none -highlight DiagnosticVirtualTextInfo ctermbg=none -highlight DiagnosticVirtualTextInfo guibg=none -highlight DiagnosticVirtualTextHint ctermbg=none -highlight DiagnosticVirtualTextHint guibg=none -]]) - --- run specific commands after different file extensions vim.cmd([[ augroup RunPfOnSave autocmd! @@ -82,7 +42,7 @@ vim.g.gitgutter_set_sign_backgrounds = 1 --Keybinds vim.g.mapleader = " " -keymap.set("n", "e", vim.cmd.Ex) +keymap.set("n", "e", vim.cmd.NvimTreeToggle) keymap.set("n", "z", [[:%s/\<\>//gI]]) keymap.set("n", "a", "ggVG") keymap.set("n", "y", "cc") @@ -106,8 +66,10 @@ end vim.opt.rtp:prepend(lazypath) require("lazy").setup({ "nvim-lua/plenary.nvim", + 'chriskempson/base16-vim', "airblade/vim-gitgutter", "lervag/vimtex", + "nvim-tree/nvim-tree.lua", "norcalli/nvim-colorizer.lua", "nvim-treesitter/nvim-treesitter", "neovim/nvim-lspconfig", @@ -178,3 +140,61 @@ for lsp, settings in pairs(lsp_servers) do settings = settings, })) end + +require("nvim-tree").setup() + +-- OR setup with some options +require("nvim-tree").setup({ + sort = { + sorter = "case_sensitive", + }, + view = { + width = 30, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = true, + }, +}) + +vim.cmd.colorscheme("base16-brewer") +vim.cmd([[ +highlight GitGutterAdd ctermbg=none guibg=none +highlight GitGutterDelete guibg=none ctermbg=none +highlight NonText guifg=none +highlight EndOfBuffer ctermfg=none ctermbg=none +highlight Normal ctermbg=none +highlight Normal guibg=none +highlight signcolumn ctermbg=none +highlight signcolumn guibg=none +highlight StatusLine ctermbg=none +highlight StatusLine guibg=none +highlight DiagnosticError ctermbg=none +highlight DiagnosticError guibg=none +highlight DiagnosticWarn ctermbg=none +highlight DiagnosticWarn guibg=none +highlight DiagnosticInfo ctermbg=none +highlight DiagnosticInfo guibg=none +highlight DiagnosticHint ctermbg=none +highlight DiagnosticHint guibg=none +highlight Pmenu ctermbg=none guibg=none + +highlight DiagnosticVirtualError ctermbg=none +highlight DiagnosticVirtualError guibg=none +highlight DiagnosticVirtualWarn ctermbg=none +highlight DiagnosticVirtualWarn guibg=none +highlight DiagnosticVirtualInfo ctermbg=none +highlight DiagnosticVirtualInfo guibg=none +highlight DiagnosticVirtualHint ctermbg=none +highlight DiagnosticVirtualHint guibg=none + +highlight LineNr ctermbg=none guibg=none +highlight StatusLineNc ctermbg=none guibg=none + +highlight DiagnosticVirtualTextError ctermbg=none guibg=none +highlight DiagnosticVirtualTextWarn ctermbg=none guibg=none +highlight DiagnosticVirtualTextInfo ctermbg=none guibg=none +highlight DiagnosticVirtualTextHint ctermbg=none guibg=none +]]) -- cgit v1.2.3 From 7613551a53b2d795709f93e9344fd165e533c594 Mon Sep 17 00:00:00 2001 From: philw Date: Thu, 25 Apr 2024 13:43:24 +0200 Subject: Update nvim --- init.lua | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/init.lua b/init.lua index 5417043..534e1b3 100644 --- a/init.lua +++ b/init.lua @@ -74,6 +74,7 @@ require("lazy").setup({ "nvim-treesitter/nvim-treesitter", "neovim/nvim-lspconfig", "williamboman/mason.nvim", + "nvim-tree/nvim-web-devicons", "williamboman/mason-lspconfig.nvim", 'nvim-telescope/telescope.nvim', tag = '0.1.5', @@ -163,35 +164,30 @@ vim.cmd.colorscheme("base16-brewer") vim.cmd([[ highlight GitGutterAdd ctermbg=none guibg=none highlight GitGutterDelete guibg=none ctermbg=none +highlight GitGutterChange guibg=none ctermbg=none +highlight GitGutterChangeAdd guibg=none ctermbg=none +highlight GitGutterChangeDelete guibg=none ctermbg=none highlight NonText guifg=none highlight EndOfBuffer ctermfg=none ctermbg=none -highlight Normal ctermbg=none -highlight Normal guibg=none -highlight signcolumn ctermbg=none -highlight signcolumn guibg=none -highlight StatusLine ctermbg=none -highlight StatusLine guibg=none -highlight DiagnosticError ctermbg=none -highlight DiagnosticError guibg=none -highlight DiagnosticWarn ctermbg=none -highlight DiagnosticWarn guibg=none -highlight DiagnosticInfo ctermbg=none -highlight DiagnosticInfo guibg=none -highlight DiagnosticHint ctermbg=none -highlight DiagnosticHint guibg=none +highlight Normal ctermbg=none guibg=none +highlight signcolumn ctermbg=none guibg=none +highlight StatusLine ctermbg=none guibg=none +highlight DiagnosticError ctermbg=none guibg=none +highlight DiagnosticWarn ctermbg=none guibg=none +highlight DiagnosticInfo ctermbg=none guibg=none +highlight DiagnosticHint ctermbg=none guibg=none highlight Pmenu ctermbg=none guibg=none -highlight DiagnosticVirtualError ctermbg=none -highlight DiagnosticVirtualError guibg=none -highlight DiagnosticVirtualWarn ctermbg=none -highlight DiagnosticVirtualWarn guibg=none -highlight DiagnosticVirtualInfo ctermbg=none -highlight DiagnosticVirtualInfo guibg=none -highlight DiagnosticVirtualHint ctermbg=none -highlight DiagnosticVirtualHint guibg=none +highlight DiagnosticVirtualError ctermbg=none guibg=none +highlight DiagnosticVirtualWarn ctermbg=none guibg=none +highlight DiagnosticVirtualInfo ctermbg=none guibg=none +highlight DiagnosticVirtualHint ctermbg=none guibg=none highlight LineNr ctermbg=none guibg=none highlight StatusLineNc ctermbg=none guibg=none +highlight StatusLineNc ctermfg=none guifg=none +highlight StatusLine ctermbg=none guibg=none +highlight StatusLine ctermfg=none guifg=none highlight DiagnosticVirtualTextError ctermbg=none guibg=none highlight DiagnosticVirtualTextWarn ctermbg=none guibg=none -- cgit v1.2.3 From 2e5490858a73ab9d7ce007f019bbcd486a5f5d7a Mon Sep 17 00:00:00 2001 From: philw Date: Sun, 28 Apr 2024 14:33:07 +0200 Subject: Update config file --- init.lua | 61 ++++++++++++++++++++++++++++--------- lua/config/editor.lua | 2 +- lua/config/plugins.lua | 83 -------------------------------------------------- 3 files changed, 47 insertions(+), 99 deletions(-) delete mode 100644 lua/config/plugins.lua diff --git a/init.lua b/init.lua index 534e1b3..1864aee 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,9 @@ --- require("config.lsp") +---@diagnostic disable: undefined-global local option = vim.opt local keymap = vim.keymap vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 +vim.g.rustfmt_autosave = 1 --Basic Editor Setup option.nu = true @@ -11,6 +12,7 @@ option.softtabstop = 2 option.shiftwidth = 2 option.expandtab = true option.smartindent = true +option.ruler = false option.wrap = false option.swapfile = false option.hlsearch = false @@ -40,17 +42,7 @@ vim.g.vimtex_view_method = "zathura" vim.g.vimtex_compiler_method = "latexrun" vim.g.gitgutter_set_sign_backgrounds = 1 ---Keybinds -vim.g.mapleader = " " -keymap.set("n", "e", vim.cmd.NvimTreeToggle) -keymap.set("n", "z", [[:%s/\<\>//gI]]) -keymap.set("n", "a", "ggVG") -keymap.set("n", "y", "cc") -keymap.set("n", "", "yy") -keymap.set("n", "", "p") -keymap.set("n", "", "u") -keymap.set("v", "J", ":m '>+1gv=gv") -keymap.set("v", "K", ":m '<-2gv=gv") + local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ @@ -76,6 +68,10 @@ require("lazy").setup({ "williamboman/mason.nvim", "nvim-tree/nvim-web-devicons", "williamboman/mason-lspconfig.nvim", + 'nvimdev/lspsaga.nvim', + config = function() + require('lspsaga').setup({}) + end, 'nvim-telescope/telescope.nvim', tag = '0.1.5', dependencies = { 'nvim-lua/plenary.nvim' }, @@ -120,8 +116,27 @@ vim.api.nvim_create_autocmd("BufWritePre", { local lsp_servers = { clangd = {}, lua_ls = {}, + rust_analyzer = { + imports = { + granularity = { + group = 'module', + }, + prefix = 'self', + }, + cargo = { + buildScripts = { + enable = true, + }, + }, + procMacro = { + enable = true, + }, + }, } + +require('lspsaga').setup({}) + require("mason").setup() require("mason-lspconfig").setup { ensure_installed = lsp_servers, @@ -142,9 +157,6 @@ for lsp, settings in pairs(lsp_servers) do })) end -require("nvim-tree").setup() - --- OR setup with some options require("nvim-tree").setup({ sort = { sorter = "case_sensitive", @@ -189,8 +201,27 @@ highlight StatusLineNc ctermfg=none guifg=none highlight StatusLine ctermbg=none guibg=none highlight StatusLine ctermfg=none guifg=none +highlight NvimTreeWinSeparator ctermfg=none guifg=none +highlight CursorColumn ctermfg=none guifg=none +highlight CursorLine ctermbg=none guibg=none + +highlight VertSplit ctermbg=none guibg=none + highlight DiagnosticVirtualTextError ctermbg=none guibg=none highlight DiagnosticVirtualTextWarn ctermbg=none guibg=none highlight DiagnosticVirtualTextInfo ctermbg=none guibg=none highlight DiagnosticVirtualTextHint ctermbg=none guibg=none ]]) + +--Keybinds +vim.g.mapleader = " " +keymap.set("n", "e", vim.cmd.NvimTreeToggle) +keymap.set("n", "z", [[:%s/\<\>//gI]]) +keymap.set("n", "a", "ggVG") +keymap.set("n", "y", "cc") +keymap.set("n", "", "yy") +keymap.set("n", "", "p") +keymap.set("n", "", "u") +keymap.set("v", "J", ":m '>+1gv=gv") +keymap.set("v", "K", ":m '<-2gv=gv") +keymap.set("n", "ca", "Lspsaga code_action") diff --git a/lua/config/editor.lua b/lua/config/editor.lua index a4ce545..0649006 100644 --- a/lua/config/editor.lua +++ b/lua/config/editor.lua @@ -18,7 +18,7 @@ option.signcolumn = "number" option.autoindent = true option.clipboard = "unnamedplus" option.termguicolors = false -option.fillchars='eob: ' +option.fillchars = 'eob: ' -- Setup Editor Theme vim.cmd([[ diff --git a/lua/config/plugins.lua b/lua/config/plugins.lua deleted file mode 100644 index dd09a4d..0000000 --- a/lua/config/plugins.lua +++ /dev/null @@ -1,83 +0,0 @@ --- vim.cmd([[packadd packer.nvim]]) --- return require("packer").startup(function(use) --- use("neovim/nvim-lspconfig") --- use("lervag/vimtex") --- use({ --- "VonHeikemen/lsp-zero.nvim", --- requires = { --- { "neovim/nvim-lspconfig" }, --- { "williamboman/mason.nvim" }, --- { "williamboman/mason-lspconfig.nvim" }, --- { "hrsh7th/nvim-cmp" }, --- { "hrsh7th/cmp-buffer" }, --- { "hrsh7th/cmp-path" }, --- { "saadparwaiz1/cmp_luasnip" }, --- { "hrsh7th/cmp-nvim-lsp" }, --- { "hrsh7th/cmp-nvim-lua" }, --- { "rafamadriz/friendly-snippets" }, --- }, --- }) --- use({ --- "L3MON4D3/LuaSnip", --- tag = "v2.*", --- run = "make install_jsregexp", --- }) --- use({ --- "iamcco/markdown-preview.nvim", --- run = "cd app && npm install", --- setup = function() --- vim.g.mkdp_filetypes = { "markdown" } --- end, --- ft = { "markdown" }, --- }) --- use({ --- "windwp/nvim-autopairs", --- config = function() --- require("nvim-autopairs").setup({}) --- end, --- }) --- end) - -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) -end - -vim.opt.rtp:prepend(lazypath) -require("lazy").setup({ - "nvim-lua/plenary.nvim", - "airblade/vim-gitgutter", - "nvim-treesitter/nvim-treesitter", - "neovim/nvim-lspconfig", - 'nvim-telescope/telescope.nvim', tag = '0.1.5', - dependencies = { 'nvim-lua/plenary.nvim' }, - "windwp/nvim-autopairs", - config = function() - require("nvim-autopairs").setup({}) - end, - { 'nvim-telescope/telescope-fzf-native.nvim', - build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', - keys= { - {"/", false}, - { "f", "Telescope find_files", desc = "Find Files" }, - { "g", "Telescope live_grep", desc = "Grep" }, - { "b", "Telescope buffers", desc = "Grep" }, - } -}, -{ - 'numToStr/Comment.nvim', - lazy = false, -}, - -{ - "ms-jpq/coq_nvim", -}, -}) - -- cgit v1.2.3 From 00ded90580ba40155adfb90d4f9aab8318140199 Mon Sep 17 00:00:00 2001 From: philw Date: Mon, 29 Apr 2024 23:44:01 +0200 Subject: Update readme and stuff --- README.md | 36 +++++++++--------------------------- init.lua | 12 ++++++++++++ 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 77b2080..fdb43f7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### Installation -Run checkhealth in your Neovim +Run checkhealth in your nvim to satisfy it's requirements ```vim :checkhealth @@ -13,21 +13,11 @@ Run checkhealth in your Neovim Make sure you analyzed the output properly: - Your neovim must be >= 0.7.0 to run this config -- You need to setup [Packer](https://github.com/wbthomason/packer.nvim) ```vim git clone --depth 1 https://github.com/wbthomason/packer.nvim\ ~/.local/share/nvim/site/pack/packer/start/packer.nvim ``` - -- You should install global python provider - -```python -pip install pynvim -``` - -- You should install clipboard tool (I use xclip but you can use something diffrent) - ### Installation > Easy way @@ -35,12 +25,12 @@ pip install pynvim You can just clone this repo to your .config folder ```bash -git clone https://github.com/dsrcr/nvim ~/.config +git clone https://codeberg.com/philw/nvim ~/.config ``` -> Recommended way +> My way -I use gnu-stow to manage my dotfiles, so I encourage you to use it too. +I use ![gnu-stow](https://www.gnu.org/software/stow/) to manage my ![dotfiles](https://codeberg.org/philw/rice), so I encourage you to use it too. Use your package manage of choice to get stow, for example: @@ -55,22 +45,14 @@ In order to do this you need an empty nvim directory in your .config folder ```bash cd ~/.config mkdir nvim -cd ~/yourDirectory -git clone https://github.com/dsrcr/nvim -stow -d ~/yourDirectory -t ~/.config/nvim nvim/ +cd ~/dir +git clone https://codeberg.org/philw/nvim +stow -d ~/dir -t ~/.config/nvim nvim/ ``` +Or use my ![script](https://codeberg.org/philw/scripts) -The last step is running this command in your neovim - -```vim -:PackerSync -``` - -This command should pull everything you need - -In the next step you will encounter a lot of errors, but don't worry about it. -Packer needs to pull specific plugins and then you need to install Treesitter's support for specific filetypes eg. lua, rust.... etc. +Everything should set up automatically. There is no need for additional setup(if there is report an error). ```bash :TSUpdate diff --git a/init.lua b/init.lua index 1864aee..3afc76a 100644 --- a/init.lua +++ b/init.lua @@ -4,6 +4,7 @@ local keymap = vim.keymap vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 vim.g.rustfmt_autosave = 1 +vim.g.mkdp_auto_start = 1 --Basic Editor Setup option.nu = true @@ -68,6 +69,15 @@ require("lazy").setup({ "williamboman/mason.nvim", "nvim-tree/nvim-web-devicons", "williamboman/mason-lspconfig.nvim", + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = "cd app && yarn install", + init = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = { "markdown" }, + }, 'nvimdev/lspsaga.nvim', config = function() require('lspsaga').setup({}) @@ -225,3 +235,5 @@ keymap.set("n", "", "u") keymap.set("v", "J", ":m '>+1gv=gv") keymap.set("v", "K", ":m '<-2gv=gv") keymap.set("n", "ca", "Lspsaga code_action") +keymap.set("n", "f", "Telescope find_files") +keymap.set("n", "g", "Telescope live_grep") -- cgit v1.2.3