aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphilw <dscr@duck.com>2024-02-17 12:42:20 +0100
committerphilw <dscr@duck.com>2024-02-17 12:42:20 +0100
commit2a3ee1c8f696e6f3a9972a05f8b5f8681c244a2e (patch)
treeaf1ef4bcdcd028ed4948734ea063e9e705995b35
parent354bdafcd6bbc2f6a63ccbf21fb741f41dbd340b (diff)
downloadneovim-2a3ee1c8f696e6f3a9972a05f8b5f8681c244a2e.tar.gz
neovim-2a3ee1c8f696e6f3a9972a05f8b5f8681c244a2e.zip
Migrate to lazy and coq
-rw-r--r--init.lua169
-rw-r--r--lua/config/editor.lua25
-rw-r--r--lua/config/lsp.lua114
-rw-r--r--lua/config/packer.lua57
-rw-r--r--lua/config/plugins.lua83
5 files changed, 307 insertions, 141 deletions
diff --git a/init.lua b/init.lua
index 45e6811..87a9b46 100644
--- a/init.lua
+++ b/init.lua
@@ -1,8 +1,165 @@
1--Open this file if you want to add new plugins 1-- require("config.lsp")
2require("config.packer") 2local option = vim.opt
3local keymap = vim.keymap
3 4
4-- Here you can find stuff related to lsp 5--Basic Editor Setup
5require("config.lsp") 6option.nu = true
7option.tabstop = 2
8option.softtabstop = 2
9option.shiftwidth = 2
10option.expandtab = true
11option.smartindent = true
12option.wrap = false
13option.swapfile = false
14option.hlsearch = false
15option.incsearch = true
16option.updatetime = 50
17option.laststatus = 0
18option.signcolumn = "number"
19option.autoindent = true
20option.clipboard = "unnamedplus"
21option.termguicolors = true
22option.fillchars = 'eob: '
23option.autoindent = true
6 24
7-- And there goes editor customization 25-- Setup Editor Theme
8require("config.editor") 26vim.cmd([[
27highlight GitGutterAdd ctermbg=none
28highlight GitGutterAdd guibg=none
29highlight NonText guifg=none
30highlight EndOfBuffer ctermfg=none ctermbg=none
31highlight Normal ctermbg=none
32highlight Normal guibg=none
33highlight signcolumn ctermbg=none
34highlight signcolumn guibg=none
35highlight StatusLine ctermbg=none
36highlight StatusLine guibg=none
37highlight DiagnosticError ctermbg=none
38highlight DiagnosticError guibg=none
39highlight DiagnosticWarn ctermbg=none
40highlight DiagnosticWarn guibg=none
41highlight DiagnosticInfo ctermbg=none
42highlight DiagnosticInfo guibg=none
43highlight DiagnosticHint ctermbg=none
44highlight DiagnosticHint guibg=none
45highlight Pmenu ctermbg=none guibg=none
46
47highlight DiagnosticVirtualError ctermbg=none
48highlight DiagnosticVirtualError guibg=none
49highlight DiagnosticVirtualWarn ctermbg=none
50highlight DiagnosticVirtualWarn guibg=none
51highlight DiagnosticVirtualInfo ctermbg=none
52highlight DiagnosticVirtualInfo guibg=none
53highlight DiagnosticVirtualHint ctermbg=none
54highlight DiagnosticVirtualHint guibg=none
55
56highlight DiagnosticVirtualTextError ctermbg=none
57highlight DiagnosticVirtualTextError guibg=none
58highlight DiagnosticVirtualTextWarn ctermbg=none
59highlight DiagnosticVirtualTextWarn guibg=none
60highlight DiagnosticVirtualTextInfo ctermbg=none
61highlight DiagnosticVirtualTextInfo guibg=none
62highlight DiagnosticVirtualTextHint ctermbg=none
63highlight DiagnosticVirtualTextHint guibg=none
64]])
65
66-- run specific commands after different file extensions
67vim.cmd([[
68augroup RunPfOnSave
69autocmd!
70autocmd BufWritePost *.js,*.ts,*.jsx,*json,*.tsx,*.css,*.html,*.yaml,*.md silent! !prettier --write %
71autocmd BufWritePost *.tex silent! :VimtexCompile
72autocmd BufWritePost *.md silent! :MarkdownPreview
73autocmd BufWritePost *.php silent! !php-cs-fixer fix %
74augroup END
75]])
76
77-- Gui options
78vim.o.guifont = "Fira Code:h7"
79vim.g.vimtex_view_method = "zathura"
80vim.g.vimtex_compiler_method = "latexrun"
81vim.g.gitgutter_set_sign_backgrounds = 1
82
83--Keybinds
84vim.g.mapleader = " "
85keymap.set("n", "<leader>e", vim.cmd.Ex)
86keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
87keymap.set("n", "<leader>a", "ggVG")
88keymap.set("v", "J", ":m '>+1<CR>gv=gv")
89keymap.set("v", "K", ":m '<-2<CR>gv=gv")
90local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
91if not vim.loop.fs_stat(lazypath) then
92 vim.fn.system({
93 "git",
94 "clone",
95 "--filter=blob:none",
96 "https://github.com/folke/lazy.nvim.git",
97 "--branch=stable", -- latest stable release
98 lazypath,
99 })
100end
101
102vim.opt.rtp:prepend(lazypath)
103require("lazy").setup({
104 "nvim-lua/plenary.nvim",
105 "airblade/vim-gitgutter",
106 "nvim-treesitter/nvim-treesitter",
107 "neovim/nvim-lspconfig",
108 "williamboman/mason.nvim",
109 "williamboman/mason-lspconfig.nvim",
110 'nvim-telescope/telescope.nvim',
111 tag = '0.1.5',
112 dependencies = { 'nvim-lua/plenary.nvim' },
113 "windwp/nvim-autopairs",
114 config = function()
115 require("nvim-autopairs").setup({})
116 end,
117 {
118 'nvim-telescope/telescope-fzf-native.nvim',
119 build =
120 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build',
121 keys = {
122 { "<leader>/", false },
123 { "<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find Files" },
124 { "<leader>g", "<cmd>Telescope live_grep<cr>", desc = "Grep" },
125 { "<leader>b", "<cmd>Telescope buffers<cr>", desc = "Grep" },
126 }
127 },
128 {
129 'numToStr/Comment.nvim',
130 },
131
132 'ms-jpq/coq_nvim',
133 { 'ms-jpq/coq.artifacts', branch = "artifacts" },
134})
135
136
137vim.api.nvim_create_autocmd('InsertEnter', {
138 command = 'COQnow --shut-up'
139})
140local lsp_servers = {
141 clangd = {},
142 lua_ls = {},
143}
144require("mason").setup()
145require("mason-lspconfig").setup {
146 ensure_installed = lsp_servers,
147 automatic_installation = true,
148}
149
150local server_maps = function(opts)
151 vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- goto def
152 vim.keymap.set("n", "<leader>k", vim.lsp.buf.hover, opts) -- see docs
153 vim.keymap.set("n", "<leader>fo", function() -- format
154 vim.lsp.buf.format({ async = true })
155 end, opts)
156end
157
158for lsp, settings in pairs(lsp_servers) do
159 require("lspconfig")[lsp].setup(coq.lsp_ensure_capabilities({
160 on_attach = function(_, buffer)
161 server_maps({ buffer = buffer })
162 end,
163 settings = settings,
164 }))
165end
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 @@
1local js_based_languages = { "typescript", "javascript", "typescriptreact", "javascriptreact" }
2local option = vim.opt 1local option = vim.opt
3local keymap = vim.keymap 2local keymap = vim.keymap
4 3
5local telescope = require("telescope.builtin")
6local autotag = require("nvim-ts-autotag").setup()
7
8--Basic Editor Setup 4--Basic Editor Setup
9option.nu = true 5option.nu = true
10option.tabstop = 2 6option.tabstop = 2
@@ -21,13 +17,15 @@ option.laststatus = 0
21option.signcolumn = "number" 17option.signcolumn = "number"
22option.autoindent = true 18option.autoindent = true
23option.clipboard = "unnamedplus" 19option.clipboard = "unnamedplus"
24option.termguicolors = true 20option.termguicolors = false
21option.fillchars='eob: '
25 22
26-- Setup Editor Theme 23-- Setup Editor Theme
27vim.cmd.colorscheme("tokyonight")
28vim.cmd([[ 24vim.cmd([[
29highlight GitGutterAdd ctermbg=none 25highlight GitGutterAdd ctermbg=none
30highlight GitGutterAdd guibg=none 26highlight GitGutterAdd guibg=none
27highlight NonText guifg=none
28highlight EndOfBuffer ctermfg=none ctermbg=none
31highlight Normal ctermbg=none 29highlight Normal ctermbg=none
32highlight Normal guibg=none 30highlight Normal guibg=none
33highlight signcolumn ctermbg=none 31highlight signcolumn ctermbg=none
@@ -62,7 +60,6 @@ highlight DiagnosticVirtualTextHint ctermbg=none
62highlight DiagnosticVirtualTextHint guibg=none 60highlight DiagnosticVirtualTextHint guibg=none
63]]) 61]])
64 62
65
66-- run specific commands after different file extensions 63-- run specific commands after different file extensions
67vim.cmd([[ 64vim.cmd([[
68augroup RunPfOnSave 65augroup RunPfOnSave
@@ -83,21 +80,7 @@ vim.g.gitgutter_set_sign_backgrounds = 1
83--Keybinds 80--Keybinds
84vim.g.mapleader = " " 81vim.g.mapleader = " "
85keymap.set("n", "<leader>e", vim.cmd.Ex) 82keymap.set("n", "<leader>e", vim.cmd.Ex)
86keymap.set("n", "<leader>f", telescope.find_files, {})
87keymap.set("n", "<leader>fg", telescope.live_grep, {})
88keymap.set("n", "<leader>fb", telescope.buffers, {})
89keymap.set("n", "<leader>fh", telescope.help_tags, {})
90keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) 83keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
91keymap.set("n", "<leader>a", "ggVG") 84keymap.set("n", "<leader>a", "ggVG")
92keymap.set("v", "J", ":m '>+1<CR>gv=gv") 85keymap.set("v", "J", ":m '>+1<CR>gv=gv")
93keymap.set("v", "K", ":m '<-2<CR>gv=gv") 86keymap.set("v", "K", ":m '<-2<CR>gv=gv")
94
95--Treesitter
96require("nvim-treesitter.configs").setup({
97 ensure_installed = { "javascript", "typescript", "rust", "c", "lua", "vim" },
98 sync_install = false,
99 auto_install = true,
100 highlight = {
101 enable = true,
102 },
103})
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 @@
1-- local lsp = require('lsp-zero') 1-- local lsp = require('lsp-zero')
2 2
3local lsp_zero = require("lsp-zero") 3--local lsp_zero = require("lsp-zero")
4local cmp = require("cmp") 4--local cmp = require("cmp")
5require("luasnip.loaders.from_vscode").lazy_load() 5--require("luasnip.loaders.from_vscode").lazy_load()
6 6
7lsp_zero.preset("recommended") 7--lsp_zero.preset("recommended")
8lsp_zero.setup() 8--lsp_zero.setup()
9lsp_zero.on_attach(function(client_id, bufnr) 9--lsp_zero.on_attach(function(client_id, bufnr)
10 lsp_zero.default_keymaps({ buffer = bufnr }) 10-- lsp_zero.default_keymaps({ buffer = bufnr })
11end) 11--end)
12 12
13require("mason").setup({}) 13--require("mason").setup({})
14require("mason-lspconfig").setup({ 14--require("mason-lspconfig").setup({
15 ensure_installed = { "clangd", "rust_analyzer" }, 15-- ensure_installed = { "clangd", "rust_analyzer" },
16 handlers = { 16-- handlers = {
17 lsp_zero.default_setup, 17-- lsp_zero.default_setup,
18 }, 18-- },
19}) 19--})
20 20
21cmp.setup({ 21--cmp.setup({
22 snippet = { 22-- snippet = {
23 expand = function(args) 23-- expand = function(args)
24 require("luasnip").lsp_expand(args.body) 24-- require("luasnip").lsp_expand(args.body)
25 end, 25-- end,
26 }, 26-- },
27 window = {}, 27-- window = {},
28 mapping = cmp.mapping.preset.insert({ 28-- mapping = cmp.mapping.preset.insert({
29 ["<C-b>"] = cmp.mapping.scroll_docs(-4), 29-- ["<C-b>"] = cmp.mapping.scroll_docs(-4),
30 ["<C-f>"] = cmp.mapping.scroll_docs(4), 30-- ["<C-f>"] = cmp.mapping.scroll_docs(4),
31 ["<C-Space>"] = cmp.mapping.complete(), 31-- ["<C-Space>"] = cmp.mapping.complete(),
32 ["<C-e>"] = cmp.mapping.abort(), 32-- ["<C-e>"] = cmp.mapping.abort(),
33 ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. 33-- ["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
34 }), 34-- }),
35 sources = cmp.config.sources({ 35-- sources = cmp.config.sources({
36 { name = "nvim_lsp" }, 36-- { name = "nvim_lsp" },
37 { name = "luasnip" }, 37-- { name = "luasnip" },
38 }, { 38-- }, {
39 { name = "buffer" }, 39-- { name = "buffer" },
40 }), 40-- }),
41}) 41--})
42 42
43function PrintDiagnostics(opts, bufnr, line_nr, client_id) 43--function PrintDiagnostics(opts, bufnr, line_nr, client_id)
44 bufnr = bufnr or 0 44-- bufnr = bufnr or 0
45 line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1) 45-- line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1)
46 opts = opts or { ["lnum"] = line_nr } 46-- opts = opts or { ["lnum"] = line_nr }
47--
48-- local line_diagnostics = vim.diagnostic.get(bufnr, opts)
49-- if vim.tbl_isempty(line_diagnostics) then
50-- return
51-- end
52--
53-- local diagnostic_message = ""
54-- for i, diagnostic in ipairs(line_diagnostics) do
55-- diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "")
56-- print(diagnostic_message)
57-- if i ~= #line_diagnostics then
58-- diagnostic_message = diagnostic_message .. "\n"
59-- end
60-- end
61-- vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {})
62--end
47 63
48 local line_diagnostics = vim.diagnostic.get(bufnr, opts) 64--vim.cmd([[ autocmd! CursorHold * lua PrintDiagnostics() ]])
49 if vim.tbl_isempty(line_diagnostics) then
50 return
51 end
52
53 local diagnostic_message = ""
54 for i, diagnostic in ipairs(line_diagnostics) do
55 diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "")
56 print(diagnostic_message)
57 if i ~= #line_diagnostics then
58 diagnostic_message = diagnostic_message .. "\n"
59 end
60 end
61 vim.api.nvim_echo({ { diagnostic_message, "Normal" } }, false, {})
62end
63
64vim.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 @@
1vim.cmd([[packadd packer.nvim]])
2return require("packer").startup(function(use)
3 use("wbthomason/packer.nvim")
4 use("nvim-treesitter/nvim-treesitter")
5 use("neovim/nvim-lspconfig")
6 use("lukas-reineke/indent-blankline.nvim")
7 use("lervag/vimtex")
8 use("folke/tokyonight.nvim")
9 use("airblade/vim-gitgutter")
10 use("jose-elias-alvarez/null-ls.nvim")
11 use("windwp/nvim-ts-autotag")
12 use({
13 "nvim-telescope/telescope.nvim",
14 tag = "0.1.4",
15 requires = { { "nvim-lua/plenary.nvim" } },
16 })
17 use({
18 "VonHeikemen/lsp-zero.nvim",
19 requires = {
20 { "neovim/nvim-lspconfig" },
21 { "williamboman/mason.nvim" },
22 { "williamboman/mason-lspconfig.nvim" },
23 { "hrsh7th/nvim-cmp" },
24 { "hrsh7th/cmp-buffer" },
25 { "hrsh7th/cmp-path" },
26 { "saadparwaiz1/cmp_luasnip" },
27 { "hrsh7th/cmp-nvim-lsp" },
28 { "hrsh7th/cmp-nvim-lua" },
29 { "rafamadriz/friendly-snippets" },
30 },
31 })
32 use({
33 "L3MON4D3/LuaSnip",
34 tag = "v2.*",
35 run = "make install_jsregexp",
36 })
37 use({
38 "numToStr/Comment.nvim",
39 config = function()
40 require("Comment").setup()
41 end,
42 })
43 use({
44 "iamcco/markdown-preview.nvim",
45 run = "cd app && npm install",
46 setup = function()
47 vim.g.mkdp_filetypes = { "markdown" }
48 end,
49 ft = { "markdown" },
50 })
51 use({
52 "windwp/nvim-autopairs",
53 config = function()
54 require("nvim-autopairs").setup({})
55 end,
56 })
57end)
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 @@
1-- vim.cmd([[packadd packer.nvim]])
2-- return require("packer").startup(function(use)
3-- use("neovim/nvim-lspconfig")
4-- use("lervag/vimtex")
5-- use({
6-- "VonHeikemen/lsp-zero.nvim",
7-- requires = {
8-- { "neovim/nvim-lspconfig" },
9-- { "williamboman/mason.nvim" },
10-- { "williamboman/mason-lspconfig.nvim" },
11-- { "hrsh7th/nvim-cmp" },
12-- { "hrsh7th/cmp-buffer" },
13-- { "hrsh7th/cmp-path" },
14-- { "saadparwaiz1/cmp_luasnip" },
15-- { "hrsh7th/cmp-nvim-lsp" },
16-- { "hrsh7th/cmp-nvim-lua" },
17-- { "rafamadriz/friendly-snippets" },
18-- },
19-- })
20-- use({
21-- "L3MON4D3/LuaSnip",
22-- tag = "v2.*",
23-- run = "make install_jsregexp",
24-- })
25-- use({
26-- "iamcco/markdown-preview.nvim",
27-- run = "cd app && npm install",
28-- setup = function()
29-- vim.g.mkdp_filetypes = { "markdown" }
30-- end,
31-- ft = { "markdown" },
32-- })
33-- use({
34-- "windwp/nvim-autopairs",
35-- config = function()
36-- require("nvim-autopairs").setup({})
37-- end,
38-- })
39-- end)
40
41local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
42if not vim.loop.fs_stat(lazypath) then
43 vim.fn.system({
44 "git",
45 "clone",
46 "--filter=blob:none",
47 "https://github.com/folke/lazy.nvim.git",
48 "--branch=stable", -- latest stable release
49 lazypath,
50 })
51end
52
53vim.opt.rtp:prepend(lazypath)
54require("lazy").setup({
55 "nvim-lua/plenary.nvim",
56 "airblade/vim-gitgutter",
57 "nvim-treesitter/nvim-treesitter",
58 "neovim/nvim-lspconfig",
59 'nvim-telescope/telescope.nvim', tag = '0.1.5',
60 dependencies = { 'nvim-lua/plenary.nvim' },
61 "windwp/nvim-autopairs",
62 config = function()
63 require("nvim-autopairs").setup({})
64 end,
65 { 'nvim-telescope/telescope-fzf-native.nvim',
66 build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build',
67 keys= {
68 {"<leader>/", false},
69 { "<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find Files" },
70 { "<leader>g", "<cmd>Telescope live_grep<cr>", desc = "Grep" },
71 { "<leader>b", "<cmd>Telescope buffers<cr>", desc = "Grep" },
72 }
73},
74{
75 'numToStr/Comment.nvim',
76 lazy = false,
77},
78
79{
80 "ms-jpq/coq_nvim",
81},
82})
83