aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorMax Christian Pohle2024-09-01 02:00:46 +0200
committerMax Christian Pohle2024-09-01 02:00:46 +0200
commitfe0e677564995c25119beb8238234c24ef6e592c (patch)
treee33fef58ae6a906ae89382c82ebcb541e3f3a997 /lua
parent7172c36d4508510ad844fcbea1bd3bc496da809e (diff)
downloadvim-fe0e677564995c25119beb8238234c24ef6e592c.tar.bz2
vim-fe0e677564995c25119beb8238234c24ef6e592c.zip
refactored the entire config
Diffstat (limited to 'lua')
-rw-r--r--lua/plugins/cmp.lua166
-rw-r--r--lua/plugins/colorizer.lua6
-rw-r--r--lua/plugins/devicons.lua11
-rw-r--r--lua/plugins/gitsigns.lua6
-rw-r--r--lua/plugins/orgmode.lua6
-rw-r--r--lua/plugins/popup.lua5
-rw-r--r--lua/plugins/telescope.lua13
-rw-r--r--lua/plugins/treesitter.lua20
8 files changed, 217 insertions, 16 deletions
diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua
index fed96e4..f4766db 100644
--- a/lua/plugins/cmp.lua
+++ b/lua/plugins/cmp.lua
@@ -1,11 +1,159 @@
1return { 1return {
2 'neovim/nvim-lspconfig', 2 {
3 'hrsh7th/cmp-nvim-lsp', 3 'hrsh7th/nvim-cmp',
4 'hrsh7th/cmp-buffer', 4 dependencies = {
5 'hrsh7th/cmp-path', 5 'nvim-lua/popup.nvim',
6 'hrsh7th/nvim-cmp', 6 'nvim-lua/plenary.nvim',
7 'hrsh7th/vim-vsnip', 7 'saadparwaiz1/cmp_luasnip',
8 'L3MON4D3/LuaSnip', 8 "hrsh7th/cmp-emoji",
9 'octaltree/cmp-look', 9 'hrsh7th/cmp-nvim-lsp',
10 'saadparwaiz1/cmp_luasnip', 10 'hrsh7th/cmp-buffer',
11 'hrsh7th/cmp-path',
12 'hrsh7th/vim-vsnip',
13 'octaltree/cmp-look',
14 'folke/trouble.nvim',
15 'folke/lazydev.nvim',
16 {
17 'L3MON4D3/LuaSnip',
18 config = function()
19 vim.keymap.set(
20 {"i", "s"},
21 "<leader><Tab>",
22 function() require('luasnip').jump(1) end,
23 {silent = true}
24 )
25 vim.keymap.set(
26 {"i", "s"},
27 "<leader><S-Tab>",
28 function() require('luasnip').jump(-1) end,
29 {silent = true}
30 )
31 end,
32 },
33 },
34
35 config = function()
36 require('trouble').setup()
37 require('lazydev').setup()
38
39 local cmp = require'cmp'
40 cmp.setup({
41 snippet = {
42 -- REQUIRED - you must specify a snippet engine
43 expand = function(args)
44 require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
45 -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
46 end,
47 },
48 window = {
49 completion = cmp.config.window.bordered(),
50 documentation = cmp.config.window.bordered(),
51 },
52 mapping = cmp.mapping.preset.insert({
53 ['<C-b>'] = cmp.mapping.scroll_docs(-4),
54 ['<C-f>'] = cmp.mapping.scroll_docs(4),
55 ['<C-Space>'] = cmp.mapping.complete(),
56 ['<C-e>'] = cmp.mapping.abort(),
57 ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
58 }),
59 sources = cmp.config.sources({
60 { name = 'nvim_lsp' },
61 { name = 'luasnip' }, -- For luasnip users.
62 }, {
63 { name = 'buffer' },
64 })
65 })
66 end
67 },
68 {
69 'neovim/nvim-lspconfig',
70 dependencies = {
71 { "folke/neodev.nvim" }
72 },
73 config = function()
74 -- Set up lspconfig.
75 local keymap = vim.keymap
76 local on_attach = function(client, bufnr)
77 local opts = { noremap = true, silent = true, buffer = bufnr }
78 keymap.set("n", "gf", "<cmd>Lspsaga lsp_finder<CR>", opts) -- show definition, references
79 keymap.set("n", "gD", "<Cmd>Lspsaga goto_definition<CR>", opts) -- got to declaration
80 keymap.set("n", "gd", "<cmd>Lspsaga peek_definition<CR>", opts) -- see definition and make edits in window
81 keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) -- go to implementation
82 keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts) -- see available code actions
83 keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename
84 keymap.set("n", "<leader>D", "<cmd>Lspsaga show_line_diagnostics<CR>", opts) -- show diagnostics for line
85 keymap.set("n", "<leader>d", "<cmd>Lspsaga show_cursor_diagnostics<CR>", opts) -- show diagnostics for cursor
86 keymap.set("n", "[d", "<cmd>Lspsaga diagnostic_jump_prev<CR>", opts) -- jump to previous diagnostic in buffer
87 keymap.set("n", "]d", "<cmd>Lspsaga diagnostic_jump_next<CR>", opts) -- jump to next diagnostic in buffer
88 keymap.set("n", "K", "<cmd>Lspsaga hover_doc<CR>", opts) -- show documentation for what is under cursor
89 keymap.set("n", "<leader>o", "<cmd>LSoutlineToggle<CR>", opts) -- see outline on right hand side
90 keymap.set("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
91 vim.keymap.set("n", "<C-n>", ":cnext<CR>")
92 vim.keymap.set("n", "<C-p>", ":cprev<CR>")
93 end
94
95 local capabilities = require("cmp_nvim_lsp").default_capabilities()
96
97 -- # Language Servers
98 -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
99 for _,server in ipairs({
100 'bitbake_language_server',
101 "clangd", -- C/C++ | clang
102 "tsserver", -- javascript | typescript-language-server
103 "lua_ls", -- lua (but not init.lua entirely, hence why neodev)
104 "jdtls",
105 "html",
106 "cssls", -- ccs | vscode-css-languageserver
107 "rust_analyzer", -- rust | rust-analyzer
108 "eslint", -- javascript | eslint
109 'vimls', -- vimscript | vim-language-server
110 'html', -- html
111 'jsonls', -- jsonls
112 "pyright", -- python
113 "bashls", -- bash | bash-language-server
114 "gopls",
115 "emmet_ls",
116 "marksman"}) do
117 require("lspconfig")[server].setup({
118 capabilities = capabilities,
119 on_attach = on_attach
120 })
121 end
122
123 -- # specialized config for some LSPs which have non-ideal defaults
124 --
125 -- require('lspconfig')['java_language_server'].setup{ cmd = { "/usr/share/java/java-language-server/lang_server_linux.sh" }, root_dir = function () return vim.fn.getcwd() end }
126 -- configure html server
127 require('lspconfig')["html"].setup({
128 init_options = {
129 configurationSection = { "html", "css", "javascript" },
130 embeddedLanguages = {
131 css = true,
132 javascript = true,
133 },
134 provideFormatter = true,
135 },
136 })
137 require('lspconfig')['pylsp'].setup{
138 settings = {
139 pylsp = {
140 plugins = {
141 pycodestyle = {
142 ignore = {'W391'},
143 maxLineLength = 100
144 }
145 }
146 }
147 }
148 }
149 require("lspconfig").clangd.setup {
150 on_attach = on_attach,
151 capabilities = capabilities,
152 cmd = {
153 "clangd",
154 "--offset-encoding=utf-16",
155 },
156 }
157 end
158 }
11} 159}
diff --git a/lua/plugins/colorizer.lua b/lua/plugins/colorizer.lua
new file mode 100644
index 0000000..416f2d1
--- /dev/null
+++ b/lua/plugins/colorizer.lua
@@ -0,0 +1,6 @@
1return {
2 'norcalli/nvim-colorizer.lua',
3 config = function()
4 require('colorizer').setup()
5 end,
6}
diff --git a/lua/plugins/devicons.lua b/lua/plugins/devicons.lua
new file mode 100644
index 0000000..9e69c5f
--- /dev/null
+++ b/lua/plugins/devicons.lua
@@ -0,0 +1,11 @@
1
2return {
3 'nvim-tree/nvim-web-devicons',
4 config = function()
5 require'nvim-web-devicons'.setup {
6 color_icons = true;
7 default = true;
8 strict = true;
9 }
10 end,
11}
diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua
new file mode 100644
index 0000000..d88bf68
--- /dev/null
+++ b/lua/plugins/gitsigns.lua
@@ -0,0 +1,6 @@
1return {
2 'lewis6991/gitsigns.nvim',
3 config = function()
4 require('gitsigns').setup()
5 end,
6}
diff --git a/lua/plugins/orgmode.lua b/lua/plugins/orgmode.lua
index fe09f3e..a9d6ea0 100644
--- a/lua/plugins/orgmode.lua
+++ b/lua/plugins/orgmode.lua
@@ -3,15 +3,9 @@ return {
3 event = 'VeryLazy', 3 event = 'VeryLazy',
4 ft = { 'org' }, 4 ft = { 'org' },
5 config = function() 5 config = function()
6 -- Setup orgmode
7 require('orgmode').setup({ 6 require('orgmode').setup({
8 org_agenda_files = '~/orgfiles/**/*', 7 org_agenda_files = '~/orgfiles/**/*',
9 org_default_notes_file = '~/orgfiles/refile.org', 8 org_default_notes_file = '~/orgfiles/refile.org',
10 }) 9 })
11 require('cmp').setup({
12 sources = {
13 { name = 'orgmode' }
14 }
15 })
16 end, 10 end,
17} 11}
diff --git a/lua/plugins/popup.lua b/lua/plugins/popup.lua
new file mode 100644
index 0000000..0ff2e3a
--- /dev/null
+++ b/lua/plugins/popup.lua
@@ -0,0 +1,5 @@
1return {
2 'nvim-lua/plenary.nvim',
3 'nvim-lua/popup.nvim',
4}
5
diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua
index ed65c3f..fee09df 100644
--- a/lua/plugins/telescope.lua
+++ b/lua/plugins/telescope.lua
@@ -1,4 +1,15 @@
1return { 1return {
2 'nvim-telescope/telescope.nvim', 2 'nvim-telescope/telescope.nvim',
3 'nvim-telescope/telescope-media-files.nvim', 3 dependencies = {
4 'nvim-telescope/telescope-media-files.nvim'
5 },
6 config = function()
7 require('telescope').load_extension('media_files')
8
9 local builtin = require('telescope.builtin')
10 vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
11 vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
12 vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
13 vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
14 end,
4} 15}
diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua
new file mode 100644
index 0000000..9673f63
--- /dev/null
+++ b/lua/plugins/treesitter.lua
@@ -0,0 +1,20 @@
1return {
2 -- treesitter is experimental and breaks indentation on xml, html with `=`
3 -- treesitter is optional for orgmode, but without it syntax highlighting in
4 -- org files is broken
5 'nvim-treesitter/nvim-treesitter',
6 config = function()
7 require'nvim-treesitter.configs'.setup {
8 ensure_installed = {"c", "html", "css", "javascript", "org"},
9 sync_install = false,
10 auto_install = true,
11 ignore_install = {},
12 disable = { },
13 modules = { "all" },
14 highlight = {
15 enable = true,
16 }
17 }
18 end
19}
20
..