diff --git a/init.lua b/init.lua index 9015a64e..5a027769 100644 --- a/init.lua +++ b/init.lua @@ -374,7 +374,7 @@ local on_attach = function(_, bufnr) end nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + -- nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') @@ -384,7 +384,7 @@ local on_attach = function(_, bufnr) nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- See `:help K` for why this keymap - -- nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + -- nmap('k', vim.lsp.buf.hover, 'Hover Documentation') nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') -- Lesser used LSP functionality @@ -396,9 +396,9 @@ local on_attach = function(_, bufnr) end, '[W]orkspace [L]ist Folders') -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, { desc = 'Format current buffer with LSP' }) + -- vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + -- vim.lsp.buf.format() + -- end, { desc = 'Format current buffer with LSP' }) end -- Enable the following language servers diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..4082bd88 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,6 @@ +return { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup {} + end, +} diff --git a/lua/custom/plugins/lspsaga.lua b/lua/custom/plugins/lspsaga.lua new file mode 100644 index 00000000..2b68b955 --- /dev/null +++ b/lua/custom/plugins/lspsaga.lua @@ -0,0 +1,19 @@ +return { + "glepnir/lspsaga.nvim", + event = "BufRead", + config = function() + vim.keymap.set('n', 'k', ':Lspsaga hover_doc') + vim.keymap.set('n', 'gs', ':Lspsaga signature_help') + vim.keymap.set('n', 'rn', ':Lspsaga rename') + vim.keymap.set('n', 'ca', ':Lspsaga code_action') + vim.keymap.set('n', 'gl', ':Lspsaga show_line_diagnostics') + vim.keymap.set('n', 'gn', ':Lspsaga diagnostic_jump_next') + vim.keymap.set('n', 'gp', ':Lspsaga diagnostic_jump_prev') + require("lspsaga").setup({}) + end, + dependencies = { + {"nvim-tree/nvim-web-devicons"}, + --Please make sure you install markdown and markdown_inline parser + {"nvim-treesitter/nvim-treesitter"} + } +} diff --git a/lua/custom/plugins/null-ls.lua b/lua/custom/plugins/null-ls.lua new file mode 100644 index 00000000..474410c4 --- /dev/null +++ b/lua/custom/plugins/null-ls.lua @@ -0,0 +1,54 @@ +return { + "jose-elias-alvarez/null-ls.nvim", + dependencies = {"nvim-lua/plenary.nvim"}, + config = function () + local null_ls = require("null-ls") + + local formatting = null_ls.builtins.formatting + local diagnostics = null_ls.builtins.diagnostics + local codeActions = null_ls.builtins.code_actions + + local sources = { + formatting.eslint_d, formatting.prettierd.with({ + env = { + PRETTIERD_DEFAULT_CONFIG = vim.fn.expand "~/.config/nvim/utils/linter-config/.prettierrc.js" + } + }), -- formatting.prettier + -- .with({extra_args = {'--single-quote', '--tab-width 2', '--arrow-parens avoid'}}), + formatting.lua_format.with({ + extra_args = { + '--no-keep-simple-function-one-line', '--no-break-after-operator', '--column-limit=100', + '--break-after-table-lb', '--indent-width=2' + } + }), diagnostics.eslint_d.with({diagnostics_format = "[#{c}] #{m} (#{s})"}), codeActions.eslint_d + } + + local lsp_formatting = function(bufnr) + vim.lsp.buf.format({ + filter = function(client) + -- apply whatever logic you want (in this example, we'll only use null-ls) + return client.name == "null-ls" + end, + bufnr = bufnr + }) + end + + -- if you want to set up formatting on save, you can use this as a callback + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + + local on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({group = augroup, buffer = bufnr}) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + lsp_formatting(bufnr) + end + }) + end + end + + null_ls.setup({sources = sources, debug = true, on_attach = on_attach}) + end +} diff --git a/lua/custom/plugins/nvim-cmp.lua b/lua/custom/plugins/nvim-cmp.lua new file mode 100644 index 00000000..78f1843a --- /dev/null +++ b/lua/custom/plugins/nvim-cmp.lua @@ -0,0 +1,6 @@ +return { + "rafamadriz/friendly-snippets", + config = function () + require("luasnip/loaders/from_vscode").lazy_load() + end +} diff --git a/lua/custom/plugins/nvim-colorizer.lua b/lua/custom/plugins/nvim-colorizer.lua new file mode 100644 index 00000000..113b18b3 --- /dev/null +++ b/lua/custom/plugins/nvim-colorizer.lua @@ -0,0 +1,9 @@ +return { + 'norcalli/nvim-colorizer.lua', + config = function () + require'colorizer'.setup { + '*', -- Highlight all files, but customize some others. + css = {css = true} -- Enable parsing rgb(...) functions in css. + } + end +} diff --git a/lua/custom/plugins/nvim-scrollbar.lua b/lua/custom/plugins/nvim-scrollbar.lua new file mode 100644 index 00000000..c723ddfb --- /dev/null +++ b/lua/custom/plugins/nvim-scrollbar.lua @@ -0,0 +1,16 @@ +return { + 'petertriho/nvim-scrollbar', + config = function () + require("scrollbar").setup({ + handle = {text = " "}, + marks = { + Search = {text = {"-- ", "== "}}, + Error = {text = {" ", " "}}, + Warn = {text = {" ", " "}}, + Info = {text = {" ", " "}}, + Hint = {text = {" ", " "}}, + Misc = {text = {"-- ", "== "}} + } + }) + end +} diff --git a/lua/custom/plugins/nvim-surround.lua b/lua/custom/plugins/nvim-surround.lua new file mode 100644 index 00000000..bdac1d41 --- /dev/null +++ b/lua/custom/plugins/nvim-surround.lua @@ -0,0 +1,6 @@ +return { + "kylechui/nvim-surround", + config = function() + require("nvim-surround").setup({}) + end +} diff --git a/lua/custom/plugins/nvimtree.lua b/lua/custom/plugins/nvimtree.lua index 5a6842c9..14145d3a 100644 --- a/lua/custom/plugins/nvimtree.lua +++ b/lua/custom/plugins/nvimtree.lua @@ -23,6 +23,13 @@ return { bufferline_api.set_offset(0) end) - require("nvim-tree").setup() + require("nvim-tree").setup({ + sync_root_with_cwd = true, + respect_buf_cwd = true, + update_focused_file = { + enable = true, + update_root = true + }, + }) end } diff --git a/lua/custom/plugins/project-nvim.lua b/lua/custom/plugins/project-nvim.lua new file mode 100644 index 00000000..9b000864 --- /dev/null +++ b/lua/custom/plugins/project-nvim.lua @@ -0,0 +1,6 @@ +return { + "ahmedkhalf/project.nvim", + config = function() + require("project_nvim").setup {} + end +} diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua new file mode 100644 index 00000000..8a63e6a2 --- /dev/null +++ b/lua/custom/plugins/telescope.lua @@ -0,0 +1,73 @@ +return { + 'nvim-telescope/telescope.nvim', + version = '*', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function () + -- Find files using lua fuctions + local opts = { silent = true, noremap = true } + vim.api.nvim_set_keymap('n', 'ff', "lua require'telescope.builtin'.find_files()", {silent=false, noremap=true}) + vim.api.nvim_set_keymap('n', 'fg', "lua require'telescope.builtin'.live_grep()", opts) + vim.api.nvim_set_keymap('n', 'fs', "lua require'telescope.builtin'.grep_string()", opts) + vim.api.nvim_set_keymap('n', 'ft', "lua require'telescope.builtin'.file_browser()", opts) + vim.api.nvim_set_keymap('n', 'fo', "lua require'telescope.builtin'.oldfiles()", opts) + vim.api.nvim_set_keymap('n', 'gc', "lua require'telescope.builtin'.git_commits()", opts) + vim.api.nvim_set_keymap('n', 'gb', "lua require'telescope.builtin'.git_branches()", opts) + vim.api.nvim_set_keymap('n', 'fb', "lua require'telescope.builtin'.buffers()", opts) + vim.api.nvim_set_keymap('n', 'fh', "lua require'telescope.builtin'.help_tags()", opts) + + local actions = require('telescope.actions') + require('telescope').setup { + defaults = { + -- program to use for searching with its arguments + find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'}, + -- prompt_position = 'top', -- have prompt at the top (has no effect on vertical configuration) + prompt_prefix = ' ', -- symbol on prompt window + selection_caret = ' ', -- symbol on selected row in results window + entry_prefix = ' ', -- symbol on non-selected rows in results window + initial_mode = 'insert', -- start in insert mode + selection_strategy = 'reset', -- what happens to selection when list changes + sorting_strategy = 'ascending', -- start with most important search on top + layout_strategy = 'horizontal', -- vertical layout + layout_config = { + prompt_position = 'top' + }, + file_sorter = require'telescope.sorters'.get_fuzzy_file, + file_ignore_patterns = {'node_modules/.*'}, -- never search in node_modules/ dir + generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, + display_path = true, + winblend = 0, -- window should not be transparent + border = {}, -- no border? + borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'}, -- border chars + color_devicons = true, -- colorize used icons + use_less = true, -- less is bash program for preview file contents + set_env = {['COLORTERM'] = 'truecolor'}, -- use all the colors + 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, + buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker, + -- preview_cutoff = 120, + mappings = { + i = { + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + [''] = actions.smart_send_to_qflist + actions.open_qflist, + -- ['ć'] = actions.close, + [''] = actions.select_default + actions.center, + }, + n = { + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + [''] = actions.smart_send_to_qflist + actions.open_qflist, + ['ć'] = actions.close, + } + } + }, + extensions = { + fzy_native = { + override_generic_sorter = false, + override_file_sorter = true, + } + } + } + end +} diff --git a/lua/custom/plugins/vim-multi-select.lua b/lua/custom/plugins/vim-multi-select.lua new file mode 100644 index 00000000..f74c1cfd --- /dev/null +++ b/lua/custom/plugins/vim-multi-select.lua @@ -0,0 +1 @@ +return {'mg979/vim-visual-multi'} diff --git a/utils/linter-config/.prettierrc.js b/utils/linter-config/.prettierrc.js new file mode 100644 index 00000000..c3584619 --- /dev/null +++ b/utils/linter-config/.prettierrc.js @@ -0,0 +1,8 @@ +module.exports = { + trailingComma: 'none', + tabWidth: 2, + semi: true, + singleQuote: true, + printWidth: 80, + arrowParens: 'avoid' +};