aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Andrzej Wandzio <dscr@duck.com>2024-04-29 21:47:02 +0000
committerFilip Andrzej Wandzio <dscr@duck.com>2024-04-29 21:47:02 +0000
commit9973865685cbf6524de9d2d74dfa2a0b9c00fb8c (patch)
treecbd7455f9859f7cffb633834e3b573885209255a
parent354bdafcd6bbc2f6a63ccbf21fb741f41dbd340b (diff)
parent00ded90580ba40155adfb90d4f9aab8318140199 (diff)
downloadneovim-9973865685cbf6524de9d2d74dfa2a0b9c00fb8c.tar.gz
neovim-9973865685cbf6524de9d2d74dfa2a0b9c00fb8c.zip
Merge pull request 'test' (#1) from test into master
Reviewed-on: https://codeberg.org/philw/nvim/pulls/1
Diffstat (limited to '')
-rw-r--r--README.md36
-rw-r--r--init.lua243
-rw-r--r--lua/config/editor.lua25
-rw-r--r--lua/config/lsp.lua114
-rw-r--r--lua/config/packer.lua57
5 files changed, 307 insertions, 168 deletions
diff --git a/README.md b/README.md
index 77b2080..fdb43f7 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
4 4
5### Installation 5### Installation
6 6
7Run checkhealth in your Neovim 7Run checkhealth in your nvim to satisfy it's requirements
8 8
9```vim 9```vim
10:checkhealth 10:checkhealth
@@ -13,21 +13,11 @@ Run checkhealth in your Neovim
13Make sure you analyzed the output properly: 13Make sure you analyzed the output properly:
14 14
15- Your neovim must be >= 0.7.0 to run this config 15- Your neovim must be >= 0.7.0 to run this config
16- You need to setup [Packer](https://github.com/wbthomason/packer.nvim)
17 16
18```vim 17```vim
19git clone --depth 1 https://github.com/wbthomason/packer.nvim\ 18git clone --depth 1 https://github.com/wbthomason/packer.nvim\
20 ~/.local/share/nvim/site/pack/packer/start/packer.nvim 19 ~/.local/share/nvim/site/pack/packer/start/packer.nvim
21``` 20```
22
23- You should install global python provider
24
25```python
26pip install pynvim
27```
28
29- You should install clipboard tool (I use xclip but you can use something diffrent)
30
31### Installation 21### Installation
32 22
33> Easy way 23> Easy way
@@ -35,12 +25,12 @@ pip install pynvim
35You can just clone this repo to your .config folder 25You can just clone this repo to your .config folder
36 26
37```bash 27```bash
38git clone https://github.com/dsrcr/nvim ~/.config 28git clone https://codeberg.com/philw/nvim ~/.config
39``` 29```
40 30
41> Recommended way 31> My way
42 32
43I use gnu-stow to manage my dotfiles, so I encourage you to use it too. 33I 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.
44 34
45Use your package manage of choice to get stow, for example: 35Use your package manage of choice to get stow, for example:
46 36
@@ -55,22 +45,14 @@ In order to do this you need an empty nvim directory in your .config folder
55```bash 45```bash
56cd ~/.config 46cd ~/.config
57mkdir nvim 47mkdir nvim
58cd ~/yourDirectory 48cd ~/dir
59git clone https://github.com/dsrcr/nvim 49git clone https://codeberg.org/philw/nvim
60stow -d ~/yourDirectory -t ~/.config/nvim nvim/ 50stow -d ~/dir -t ~/.config/nvim nvim/
61 51
62``` 52```
53Or use my ![script](https://codeberg.org/philw/scripts)
63 54
64The last step is running this command in your neovim 55Everything should set up automatically. There is no need for additional setup(if there is report an error).
65
66```vim
67:PackerSync
68```
69
70This command should pull everything you need
71
72In the next step you will encounter a lot of errors, but don't worry about it.
73Packer needs to pull specific plugins and then you need to install Treesitter's support for specific filetypes eg. lua, rust.... etc.
74 56
75```bash 57```bash
76:TSUpdate 58:TSUpdate
diff --git a/init.lua b/init.lua
index 45e6811..3afc76a 100644
--- a/init.lua
+++ b/init.lua
@@ -1,8 +1,239 @@
1--Open this file if you want to add new plugins 1---@diagnostic disable: undefined-global
2require("config.packer") 2local option = vim.opt
3local keymap = vim.keymap
4vim.g.loaded_netrw = 1
5vim.g.loaded_netrwPlugin = 1
6vim.g.rustfmt_autosave = 1
7vim.g.mkdp_auto_start = 1
3 8
4-- Here you can find stuff related to lsp 9--Basic Editor Setup
5require("config.lsp") 10option.nu = true
11option.tabstop = 2
12option.softtabstop = 2
13option.shiftwidth = 2
14option.expandtab = true
15option.smartindent = true
16option.ruler = false
17option.wrap = false
18option.swapfile = false
19option.hlsearch = false
20option.incsearch = true
21option.updatetime = 50
22option.laststatus = 0
23option.signcolumn = "number"
24option.autoindent = true
25option.clipboard = "unnamedplus"
26option.termguicolors = true
27option.fillchars = 'eob: '
28option.autoindent = true
6 29
7-- And there goes editor customization 30vim.cmd([[
8require("config.editor") 31augroup RunPfOnSave
32autocmd!
33autocmd BufWritePost *.js,*.ts,*.jsx,*json,*.tsx,*.css,*.html,*.yaml,*.md silent! !prettier --write %
34autocmd BufWritePost *.tex silent! :VimtexCompile
35autocmd BufWritePost *.md silent! :MarkdownPreview
36autocmd BufWritePost *.php silent! !php-cs-fixer fix %
37augroup END
38]])
39
40-- Gui options
41vim.o.guifont = "Fira Code:h7"
42vim.g.vimtex_view_method = "zathura"
43vim.g.vimtex_compiler_method = "latexrun"
44vim.g.gitgutter_set_sign_backgrounds = 1
45
46
47local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
48if not vim.loop.fs_stat(lazypath) then
49 vim.fn.system({
50 "git",
51 "clone",
52 "--filter=blob:none",
53 "https://github.com/folke/lazy.nvim.git",
54 "--branch=stable", -- latest stable release
55 lazypath,
56 })
57end
58
59vim.opt.rtp:prepend(lazypath)
60require("lazy").setup({
61 "nvim-lua/plenary.nvim",
62 'chriskempson/base16-vim',
63 "airblade/vim-gitgutter",
64 "lervag/vimtex",
65 "nvim-tree/nvim-tree.lua",
66 "norcalli/nvim-colorizer.lua",
67 "nvim-treesitter/nvim-treesitter",
68 "neovim/nvim-lspconfig",
69 "williamboman/mason.nvim",
70 "nvim-tree/nvim-web-devicons",
71 "williamboman/mason-lspconfig.nvim",
72 {
73 "iamcco/markdown-preview.nvim",
74 cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
75 build = "cd app && yarn install",
76 init = function()
77 vim.g.mkdp_filetypes = { "markdown" }
78 end,
79 ft = { "markdown" },
80 },
81 'nvimdev/lspsaga.nvim',
82 config = function()
83 require('lspsaga').setup({})
84 end,
85 'nvim-telescope/telescope.nvim',
86 tag = '0.1.5',
87 dependencies = { 'nvim-lua/plenary.nvim' },
88 {
89 'nvim-telescope/telescope-fzf-native.nvim',
90 build =
91 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build',
92 keys = {
93 { "<leader>/", false },
94 { "<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find Files" },
95 { "<leader>g", "<cmd>Telescope live_grep<cr>", desc = "Grep" },
96 { "<leader>b", "<cmd>Telescope buffers<cr>", desc = "Grep" },
97 { "<leader>s", "<cmd>Telescope buffers<cr>", desc = "Grep" },
98 }
99 },
100 {
101 'windwp/nvim-autopairs',
102 event = "InsertEnter",
103 opts = {}
104 },
105 {
106 'numToStr/Comment.nvim',
107 opts = {},
108 lazy = false,
109 },
110
111 'ms-jpq/coq_nvim',
112 { 'ms-jpq/coq.artifacts', branch = "artifacts" },
113})
114
115require("colorizer").setup()
116vim.api.nvim_create_autocmd('InsertEnter', {
117 command = 'COQnow --shut-up'
118})
119
120vim.api.nvim_create_autocmd("BufWritePre", {
121 callback = function()
122 vim.lsp.buf.format()
123 end,
124})
125
126local lsp_servers = {
127 clangd = {},
128 lua_ls = {},
129 rust_analyzer = {
130 imports = {
131 granularity = {
132 group = 'module',
133 },
134 prefix = 'self',
135 },
136 cargo = {
137 buildScripts = {
138 enable = true,
139 },
140 },
141 procMacro = {
142 enable = true,
143 },
144 },
145}
146
147
148require('lspsaga').setup({})
149
150require("mason").setup()
151require("mason-lspconfig").setup {
152 ensure_installed = lsp_servers,
153 automatic_installation = true,
154}
155
156local server_maps = function(opts)
157 vim.keymap.set("n", "<leader>d", vim.lsp.buf.definition, opts) -- goto def
158 vim.keymap.set("n", "<leader>k", vim.lsp.buf.hover, opts) -- see docs
159end
160
161for lsp, settings in pairs(lsp_servers) do
162 require("lspconfig")[lsp].setup(coq.lsp_ensure_capabilities({
163 on_attach = function(_, buffer)
164 server_maps({ buffer = buffer })
165 end,
166 settings = settings,
167 }))
168end
169
170require("nvim-tree").setup({
171 sort = {
172 sorter = "case_sensitive",
173 },
174 view = {
175 width = 30,
176 },
177 renderer = {
178 group_empty = true,
179 },
180 filters = {
181 dotfiles = true,
182 },
183})
184
185vim.cmd.colorscheme("base16-brewer")
186vim.cmd([[
187highlight GitGutterAdd ctermbg=none guibg=none
188highlight GitGutterDelete guibg=none ctermbg=none
189highlight GitGutterChange guibg=none ctermbg=none
190highlight GitGutterChangeAdd guibg=none ctermbg=none
191highlight GitGutterChangeDelete guibg=none ctermbg=none
192highlight NonText guifg=none
193highlight EndOfBuffer ctermfg=none ctermbg=none
194highlight Normal ctermbg=none guibg=none
195highlight signcolumn ctermbg=none guibg=none
196highlight StatusLine ctermbg=none guibg=none
197highlight DiagnosticError ctermbg=none guibg=none
198highlight DiagnosticWarn ctermbg=none guibg=none
199highlight DiagnosticInfo ctermbg=none guibg=none
200highlight DiagnosticHint ctermbg=none guibg=none
201highlight Pmenu ctermbg=none guibg=none
202
203highlight DiagnosticVirtualError ctermbg=none guibg=none
204highlight DiagnosticVirtualWarn ctermbg=none guibg=none
205highlight DiagnosticVirtualInfo ctermbg=none guibg=none
206highlight DiagnosticVirtualHint ctermbg=none guibg=none
207
208highlight LineNr ctermbg=none guibg=none
209highlight StatusLineNc ctermbg=none guibg=none
210highlight StatusLineNc ctermfg=none guifg=none
211highlight StatusLine ctermbg=none guibg=none
212highlight StatusLine ctermfg=none guifg=none
213
214highlight NvimTreeWinSeparator ctermfg=none guifg=none
215highlight CursorColumn ctermfg=none guifg=none
216highlight CursorLine ctermbg=none guibg=none
217
218highlight VertSplit ctermbg=none guibg=none
219
220highlight DiagnosticVirtualTextError ctermbg=none guibg=none
221highlight DiagnosticVirtualTextWarn ctermbg=none guibg=none
222highlight DiagnosticVirtualTextInfo ctermbg=none guibg=none
223highlight DiagnosticVirtualTextHint ctermbg=none guibg=none
224]])
225
226--Keybinds
227vim.g.mapleader = " "
228keymap.set("n", "<leader>e", vim.cmd.NvimTreeToggle)
229keymap.set("n", "<leader>z", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
230keymap.set("n", "<leader>a", "ggVG")
231keymap.set("n", "<leader>y", "cc")
232keymap.set("n", "<C-c>", "yy")
233keymap.set("n", "<C-v>", "p")
234keymap.set("n", "<C-z>", "u")
235keymap.set("v", "J", ":m '>+1<CR>gv=gv")
236keymap.set("v", "K", ":m '<-2<CR>gv=gv")
237keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<cr>")
238keymap.set("n", "<leader>f", "<cmd>Telescope find_files<cr>")
239keymap.set("n", "<leader>g", "<cmd>Telescope live_grep<cr>")
diff --git a/lua/config/editor.lua b/lua/config/editor.lua
index eec0e08..0649006 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)