diff --git a/init.lua b/init.lua index 9f60521..a73105b 100644 --- a/init.lua +++ b/init.lua @@ -24,6 +24,7 @@ require("lazy").setup({ 'TamaMcGlinn/vim-termhere', --simple terminal QOL "smjonas/inc-rename.nvim", --lsp plugin for renaming variable 'basola21/PDFview', -- rendering pdfs in nvim + 'preservim/nerdtree', { 'norcalli/nvim-colorizer.lua', config = function() require('colorizer').setup{"*"} end,}, -- preview colors {'NMAC427/guess-indent.nvim', config = function() require('guess-indent').setup {} end,}, -- Detect tabstop and shiftwidth automatically { 'edluffy/hologram.nvim', auto_display = true,}, --image viewer @@ -35,7 +36,7 @@ require("lazy").setup({ }, -- Configure any other settings here. See the documentation for more details. -- colorscheme that will be used when installing plugins. - -- install = { colorscheme = { "habamax" } }, + install = { colorscheme = { "miniautumn" } }, -- automatically check for plugin updates checker = { enabled = true }, }) @@ -45,3 +46,5 @@ if theme_ok then matugen.setup() end +-- setup lsp +require("config.lsp") diff --git a/lazy-lock.json b/lazy-lock.json index 95733fc..53902c5 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -10,15 +10,18 @@ "inc-rename.nvim": { "branch": "main", "commit": "0074b551a17338ccdcd299bd86687cc651bcb33d" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a324581a3c83fdacdb9804b79de1cbe00ce18550" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, "mini.nvim": { "branch": "main", "commit": "9d359222b3643f1fccbd8f3180445842e1cae00b" }, "mini.pick": { "branch": "main", "commit": "8521fe21df86e08d9e4b3c3f3a7d50e47954e1af" }, "neogit": { "branch": "master", "commit": "8fd90675caf8b847280ca56f464b66030adad876" }, + "nerdtree": { "branch": "master", "commit": "690d061b591525890f1471c6675bcb5bdc8cdff9" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-dap": { "branch": "master", "commit": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5" }, "nvim-java": { "branch": "main", "commit": "602a5f7fa92f9c1d425a2159133ff9de86842f0a" }, + "nvim-lspconfig": { "branch": "master", "commit": "d8bf4c47385340ab2029402201d4d7c9f99f437a" }, "nvim-treesitter": { "branch": "main", "commit": "5cb05e1b0fa3c469958a2b26f36b3fe930af221c" }, - "nvim-treesitter-textobjects": { "branch": "main", "commit": "4e91b5d0394329a229725b021a8ea217099826ef" }, "nvim-web-devicons": { "branch": "master", "commit": "737cf6c657898d0c697311d79d361288a1343d50" }, "obsidian.nvim": { "branch": "main", "commit": "350586c9e873143c3f65e3c2667bd0324964e89c" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 4991bcd..04556f1 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -23,4 +23,11 @@ vim.api.nvim_create_autocmd("VimLeave", { set_kitty_opacity(default_opacity) end, }) +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.hl.on_yank() + end, +}) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..99ca0df --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1,47 @@ +-- lsp config +require('lspconfig') +local lsp_servers = { + 'clangd', + 'pyright', + 'lua_ls', +} +for _, server in ipairs(lsp_servers) do + local config = {} + + -- Special settings for Lua + if server == 'lua_ls' then + config.settings = { + Lua = { + diagnostics = { + -- Tell the language server that 'vim' is a global + globals = { 'vim' }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + }, + } + end + + -- Apply the config and enable + vim.lsp.config(server, config) + vim.lsp.enable(server) +end +-- highlight error messages +vim.diagnostic.config({ + virtual_text = { + prefix = '■', + spacing = 4, + }, + -- Show signs in the gutter (left side) + signs = true, + -- Underline the actual code that has the error + underline = true, + -- Don't update diagnostics while typing (keeps it less distracting) + update_in_insert = true, + -- Better looking border for float windows + float = { border = "rounded" }, +}) + diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 5802382..99fbb6f 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -1,11 +1,3 @@ --- [[ Basic Autocommands ]] -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.hl.on_yank() - end, -}) -- move betwwen buffer easier vim.keymap.set('n', '', ':bnext') vim.keymap.set('n', '', ':bprev') @@ -15,11 +7,8 @@ vim.keymap.set('n', 'x', ':bdelete') vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) - vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - -vim.keymap.set("n", "a", ":IncRename ", {desc = 'ren[a]me variable under cursor'}) - +-- vim.keymap.set("n", "a", ":IncRename ", {desc = 'ren[A]me variable under cursor'}) vim .keymap.set('n','r','TermExec cmd="clear && make"', { desc = '[r]un make in terminal' }) vim .keymap .set('n','n', 'ToggleTerm direction=vertical name=compile size=70', { desc = 'open a [n]ew terminal' }) vim.keymap.set('n','t', 'ToggleTerm', {desc = '[T]oggle all terminals'}) @@ -41,7 +30,6 @@ vim.keymap.set("n", "l", function() -- Return logic end, { desc = "Run [L]ast command in terminal 1" }) --- more keybinds -- TIP: Disable arrow keys in normal mode vim.keymap.set('n', '', 'echo "Use h to move!!"') vim.keymap.set('n', '', 'echo "Use l to move!!"') @@ -63,3 +51,4 @@ vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +vim.keymap.set("n", "e", "NERDTreeToggle", {desc = 'open [E]xplorer'}) diff --git a/lua/options.lua b/lua/options.lua index 2ec6c63..6852dd0 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -57,5 +57,6 @@ vim.opt.termguicolors = true -- required for colorizer --set background color on entering and leaving nvim require('autocommands') +vim.env.PATH = vim.fn.stdpath("data") .. "/mason/bin" .. ":" .. vim.env.PATH diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..2b3078b --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,7 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + { "mason-org/mason.nvim", config = true }, -- The "App Store" + { "mason-org/mason-lspconfig.nvim", config = true }, -- The "Bridge" + }, + } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..e9a3830 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,34 @@ +return { + "nvim-treesitter/nvim-treesitter", + opts = { + indent = { enable = true }, + highlight = { enable = true }, + folds = { enable = true }, + ensure_installed = { + "bash", + "c", + "diff", + "html", + "javascript", + "jsdoc", + "json", + "lua", + "luadoc", + "luap", + "markdown", + "markdown_inline", + "printf", + "python", + "query", + "regex", + "toml", + "tsx", + "typescript", + "vim", + "vimdoc", + "xml", + "yaml", + }, +} +} +